使用此代码,404重定向不起作用。我没有收到任何错误。如果我输入一个不存在的网址,我只会得到一个空的白页。
代码已更新:
<IfModule mod_rewrite.c>
RewriteBase /
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ htaccess.php?q=$1 [QSA]
</IfModule>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
#RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
#RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteEngine On
RewriteBase /
ErrorDocument 404 404.php/
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ 404.php [L]
答案 0 :(得分:1)
将ErrorDocument 404 /index.php
更改为
RewriteEngine On
RewriteBase /
ErrorDocument 404 http://yourdomain.com/404.php/
RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /path/to/404.php [L]
重写规则将该URL映射到您的404.php脚本。
有关详细信息,请参阅此链接:http://httpd.apache.org/docs/current/mod/core.html#errordocument