如何使用.htaccess将错误404重定向到主页?
您好,如何将错误404重定向到带有.htaccess的主页 例如: site.com如果写入site.com/some\u site\u notforund而不是404,则会将我们重定向到主页 例2:如何使用.htaccess将错误404重定向到主页?,.htaccess,redirect,web,http-status-code-404,.htaccess,Redirect,Web,Http Status Code 404,您好,如何将错误404重定向到带有.htaccess的主页 例如: site.com如果写入site.com/some\u site\u notforund而不是404,则会将我们重定向到主页 例2: sadisic.pl如果写入sadisic.pl/some_site_notfound而不是404,则会将我们重定向到当前页面尝试: FallbackResource /index.html 或者不管主页是什么 尝试: 这对我的网站很好。我试过这段代码,它没有显示404页,但它显示了相同的UR
sadisic.pl如果写入sadisic.pl/some_site_notfound而不是404,则会将我们重定向到当前页面尝试:
FallbackResource /index.html
或者不管主页是什么
尝试:
这对我的网站很好。我试过这段代码,它没有显示404页,但它显示了相同的URL,但主页的内容
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.html [L]
ErrorDocument 404 /404.php
所有未找到的页面将显示404.php文件
在404.php文件中,您可以编写:
<?php
header('location:index.php');
?>
因此,所有未找到的页面都将转到404.php页面,并将它们重定向到index.php,或保存一个重新路由步骤,然后将以下内容放入.htaccess文件中:
ErrorDocument 404 /404.php
ErrorDocument 404/index.php就是这个?ErrorDocument 404/index.htmlHave您是否已经将AllowOverride指令设置为httpd.conf以启用.htaccess?是的,好的,我有这个代码ErrorDocument 404/witout index.html和work@Taizoito您如何允许在ClearOS Web服务器中使用Override?这不适用于我的服务器。如果你写url仍然有效,而不是为了我的目的重新定义sadisic.pl,我希望类似地重定向到sadisic.plenglish@seweryns然后您需要使用mod rewrite,请参见上面的编辑部分
。htaccess
这些行必须放在哪个部分?在
内?还是外部?最好的方法是-errordocument404/index.php
或errordocument404(添加http://infort pls)。它一直被这样的人拿走
<?php
header('location:index.php');
?>