[英]How Redirect 404page to homepage in https without changing url
我希望在不更改 URL 的情况下将不存在页面重定向到主页。
我在.htaccess
文件中使用以下代码。
ErrorDocument 404 /index.php
.htaccess 适用于 http(它不会更改 URL),但使用 https 会更改当前的 Z572D14E421E5E027B。
如果您想在不更改 URL 的情况下包含index.php
,您可以在.htaccess
中使用以下代码:
ErrorDocument 404 /index.php
此代码对 http 和 https 有效。
如果要将 http 请求重定向到 https ,可以在.htaccess
中添加以下代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
重定向错误消息:站点将重定向到主页,而不是提示 404 Not Found 错误页面:
Redirect 404 Error pages to the home page
ErrorDocument 404 http://example.com/
将不存在的页面重定向到 index.php
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
您也可以手动将下面的 html 代码插入 404.php 页面。
<head>
<meta http-equiv = "refresh" content = "2; url = https://www.URL.com/404.php" />
</head>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.