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
.htaccess将未找到的页面重定向到特定页面_.htaccess - Fatal编程技术网

.htaccess将未找到的页面重定向到特定页面

.htaccess将未找到的页面重定向到特定页面,.htaccess,.htaccess,这是我的密码 RewriteRule ^error$ error.php [QSA,L] RewriteRule ^siteuri_partenere$ siteuri_partenere.php [QSA,L] RewriteRule ^politica_de_confidentialitate$ politica_de_confidentialitate.php [QSA,L] RewriteRule ^blog - [L,NC] RewriteRule ^([^/.]+)/?$ game

这是我的密码

RewriteRule ^error$ error.php [QSA,L]
RewriteRule ^siteuri_partenere$ siteuri_partenere.php [QSA,L]
RewriteRule ^politica_de_confidentialitate$ politica_de_confidentialitate.php [QSA,L]
RewriteRule ^blog - [L,NC]

RewriteRule ^([^/.]+)/?$ game.php?weblink=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /error [L,R=302]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
所以,如果我改变这条线

RewriteRule . /error [L,R=302]


然后我测试了www.domain.com/1q2w3e,仍然重定向到/error和not to/page\u not\u found,所以我很困惑问题出在哪里?

很可能您有一些
ErrorDocument 404
指令覆盖了您的重写规则。将此代码放在根目录中。htaccess:

Options +FollowSymLinks -MultiViews
ErrorDocument 404 default
RewriteEngine On

RewriteRule ^blog - [L,NC]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^error$ error.php [L]

RewriteRule ^siteuri_partenere$ siteuri_partenere.php [L]

RewriteRule ^politica_de_confidentialitate$ politica_de_confidentialitate.php [L]

RewriteRule ^([^/.]+?)/?$ game.php?weblink=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /page_not_found [L,R=302]

您是否尝试了其他浏览器进行测试?是的,我尝试了+删除Cookie。仍然不起作用,我尝试了本地主机和网络主机,非常混乱。它是否仍然重定向到
/error
?您输入的原始URL是什么?我测试了ex localhost/1q2w3enotexistpage,但仍然重定向到/error。根据这些规则,这肯定不会发生。您必须搜索代码和/或Apache配置,以查看重定向发生的位置。
Options +FollowSymLinks -MultiViews
ErrorDocument 404 default
RewriteEngine On

RewriteRule ^blog - [L,NC]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteRule ^error$ error.php [L]

RewriteRule ^siteuri_partenere$ siteuri_partenere.php [L]

RewriteRule ^politica_de_confidentialitate$ politica_de_confidentialitate.php [L]

RewriteRule ^([^/.]+?)/?$ game.php?weblink=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /page_not_found [L,R=302]