【发布时间】:2017-01-25 15:49:31
【问题描述】:
我有一个指向它自己的域的子目录,所以我希望它有自己的 404 页面。子目录中的 .htaccess 内容如下:
ErrorDocument 404 /subdirectory/404.html
我觉得这应该可以,但是有一个问题。父目录有wordpress的安装,所以.htaccess如下
# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Set PHP handler to application/x-httpd-phpbeta on Mon Jan 11 15:10:53 MST 2016.
如果子目录中有 index.php,则用作 404 页面。 否则,无论子文件夹中的 .htaccess 是否存在,我都会收到 500 错误。是什么阻止了我的 .htaccess 工作?
【问题讨论】:
-
自定义错误信息是否有效?试试 ErrorDocument 404 "抱歉找不到页面"
-
不,我仍然得到 404。糟透了。
标签: php wordpress .htaccess http-status-code-404