[英]http://example.com, http://www.example.com and https://example.com to https://www.example.com
[英]htaccess rewrite http://example.com to http://www.example.com but https://www.example.com to https://example.com
使用.htaccess重寫,我希望擁有:
http://example.com
重定向到: http://www.example.com
: http://www.example.com
https://www.example.com
重定向到: https://example.com
: http://example.com
哪個是最好的方法?
我開始於:
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
您需要2條規則:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.