我必须永久redirect到12010个垃圾邮件主页。 有没有什么办法可以将404找不到的链接,文件和目录redirect到主页,而不会给出404错误头?
我尝试下面的Apache重写方法,但没有奏效。
<IfModule rewrite_module> Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-s RewriteRule .* index.php </IfModule>
我在使用cPanel的Apache web服务器上。 我也有根访问服务器。
快速和肮脏的解决scheme:
ErrorDocument 404 http://yoursite.example.com/
这会产生一个“302find”的回应
Location: http://yoursite.example.com
头。
为什么这个快和肮脏? 硬编码的url。 如果您的站点可以通过不同的主机名和/或协议访问(例如http / https)