【发布时间】:2014-02-02 16:34:37
【问题描述】:
我尝试在 .htacces 上使用此代码在我的页面上拥有我自己的自定义 404。
ErrorDocument 404 http://mysite.com/404.shtml
当我访问网站上不存在的页面时。它必须显示类似这样的内容
但这是它显示的那个
这是我完整的htaccess
<files .htaccess>
order allow,deny
deny from all
</files>
php_value memory_limit 170M
RewriteEngine on
Options +FollowSymlinks
Options -Indexes
RewriteCond %{REQUEST_URI} (.+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
AddDefaultCharset utf-8
RewriteRule (.*) index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mysite.com.*$ [NC]
RewriteRule ^(.*)$ http://mysite.com%{REQUEST_URI} [L,R=301]
ErrorDocument 404 http://mysite.com/404.shtml
我的htaccess的位置与网站的404.shtml和index.php一起定位
删除此代码将解决问题。我怎样才能使它与路由一起工作。
RewriteCond %{REQUEST_URI} (.+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
AddDefaultCharset utf-8
RewriteRule (.*) index.php
【问题讨论】:
-
在“它必须显示类似这样的东西”之后缺少一些东西
-
你在 Apache 下运行吗?您应该检查
.htaccess是否启用:enable htaccess on apache -
是的。 .htaccess 已启用
-
我不知道其他线路如何影响
ErrorDocument线路。但是这个看起来不错。尝试评论其他东西或将.htaccess从ErrorDocument开始逐步改写成。 -
删除此代码将使其正常工作。
RewriteCond %{REQUEST_URI} (.+)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d AddDefaultCharset utf-8 RewriteRule (.*) index.php
标签: .htaccess http-status-code-404 custom-error-pages