我目前有以下内容:
这很好用,这是代码......
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我现在面临的问题是..如何删除www。来自子域 例如https://www.subdomain.maindomain.com并将其重定向到 https://subdomain.maindomain.com
希望有人可以惹恼
答案 0 :(得分:0)
尝试:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R]
答案 1 :(得分:0)
要从子域中删除WWW,请使用以下命令:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]