首页 > 解决方案 > BAD / FAKE页面重定向到404页面不起作用

问题描述

*注意 - 网站确实指向 https 以获取 SSL 证书

好的,这是在一个实时站点上,所以我将能够提供链接进行测试。

因此,如果您访问我的网站https://thebigmmorpglist.com并放入一个随机的假页面,例如https://thebigmmorpglist.com/nosuchpage.php它将保持 URL 为https://thebigmmorpglist.com/nosuchpage.php但是有一个混乱的样式表的主页的外观。还说你去https://thebigmmorpglist.com/12-sky-2/nosuchpage.php它也会显示主页,同时将 url 保持为https://thebigmmorpglist.com/12-sky-2/nosuchpage。 php但根本没有样式表(可能是因为它在不同的目录中。我对如何解决这个问题感到很困惑,我相信我的 .htaccess 文件中的重定向是正确的。

(对不起,如果我的措辞/描述有问题)

我已经尝试更改错误页面的位置并更改重定向代码的顺序/布局。我完全不知道如何纠正这个问题,而且我在 Stack Overflow 上找不到任何可以复制我的问题的东西。

ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>

RewriteEngine On
RewriteCond %{HTTP_HOST} thebigmmorpglist\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://thebigmmorpglist.com/$1 [R,L]

我希望假页面重定向到位于我的根目录中的 error.php ......

标签: php.htaccesswebredirecturl-redirection

解决方案


由于我的网站不再是 wordpress 网站,我很愚蠢并欺骗了 https 的重定向...

不得不删除此代码

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>

固定/工作代码:

ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>

RewriteEngine On
RewriteCond %{HTTP_HOST} thebigmmorpglist\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://thebigmmorpglist.com/$1 [R,L]

推荐阅读