Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 404重定向,错误触发.htaccess_Php_.htaccess_Redirect_Http Status Code 404 - Fatal编程技术网

Php 404重定向,错误触发.htaccess

Php 404重定向,错误触发.htaccess,php,.htaccess,redirect,http-status-code-404,Php,.htaccess,Redirect,Http Status Code 404,这真的很奇怪。以下是我的设置: 我有一个404重定向的.htaccess文件:ErrorDocument 404/404.php这很好用。在404文件的顶部,我使用php重定向指向www.mysite.com/index.php 我有一个安装了wordpress的子目录:www.mysite.com/blog/index.php 无论何时我去我的博客,404页面都会在blog/index.php页面加载后被调用,但是,重定向到www.mysite.com/index.php的页面永远不会被调用

这真的很奇怪。以下是我的设置:

  • 我有一个404重定向的.htaccess文件:
    ErrorDocument 404/404.php
    这很好用。在404文件的顶部,我使用php重定向指向
    www.mysite.com/index.php

  • 我有一个安装了wordpress的子目录:
    www.mysite.com/blog/index.php

  • 无论何时我去我的博客,404页面都会在
    blog/index.php
    页面加载后被调用,但是,重定向到
    www.mysite.com/index.php
    的页面永远不会被调用。博客按预期加载

通过将当前工作目录输出到我的错误日志进行一些调试,如下所示:

  • 登陆
    www.mysite.com/blog/index.php
    :cwd是
    public\u html/blog
    ,然后调用htaccess ErrorDocument,cwd变为
    public\u html/
    。但我仍然可以像什么都没发生过一样浏览我的博客
我主要担心的是,这将在很大程度上影响我的搜索引擎优化


有人有过类似的问题或建议吗?

您是否在wordpress的/blog中使用单独的htaccess文件?还有,为什么要在404.php中执行重定向?为什么只使用
errordocument404/index.php
?是的,在/blog/中使用不同的.htaccess。这里没有定义404,删除它没有什么区别。重定向只是为了调试-404页面被点击,但是重定向没有被触发,这看起来有点奇怪。。。