[英]Redirect https://www to https://non-www
I would like that all these addresses:我想要所有这些地址:
http://www.example.com
(currently correctly redirecting with my .htaccess file) http://www.example.com
(目前使用我的 .htaccess 文件正确重定向)http://example.com
(currently correctly redirecting with my .htaccess file) http://example.com
(当前使用我的 .htaccess 文件正确重定向)https://www.example.com
(this address does not redirect) https://www.example.com
(此地址不会重定向) redirect to https://example.com
.重定向到
https://example.com
。
With the following .htaccess
file, I can only get the 1. and 2. addresses redirect to https://example.com
.使用以下
.htaccess
文件,我只能将 1. 和 2. 地址重定向到https://example.com
。
Only https://www.example.com
is still not redirecting to https://example.com
.只有
https://www.example.com
仍未重定向到https://example.com
。
Here is my .htaccess
file这是我的
.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
Your question is surely a duplicate but I can't find a decent one to point to.你的问题肯定是重复的,但我找不到一个像样的问题。
# 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.