[英]Redirect https://www to https://non-www
我想要所有这些地址:
http://www.example.com
(目前使用我的 .htaccess 文件正确重定向)http://example.com
(当前使用我的 .htaccess 文件正确重定向)https://www.example.com
(此地址不会重定向) 重定向到https://example.com
。
使用以下.htaccess
文件,我只能将 1. 和 2. 地址重定向到https://example.com
。
只有https://www.example.com
仍未重定向到https://example.com
。
这是我的.htaccess
文件
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# URL with www rewrite to https without www
RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]
# URL without www rewrite to https
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^(www\.)(.*) [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
你的问题肯定是重复的,但我找不到一个像样的问题。
# URL with wrong domain to right one + https
RewriteCond %{HTTP_HOST} !=example.com
RewriteRule .* https://example.com/$0 [L,R=301]
# URL with no https fix (domain already correct otherwise first rule would have matched)
RewriteCond %{HTTPS} =off
RewriteRule .* https://%{HTTP_HOST}/$0 [L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.