.htaccess http到https重定向,子域和通过htaccess转换的www
我需要每个对特定子域的调用。example.com.xx在开头添加www,然后将其重定向到https 目前有一个解决方案,但无法与sub.example.com.xx一起重定向到 如果我输入..,我会得到而不是 即使你必须给我 示例:.htaccess http到https重定向,子域和通过htaccess转换的www,.htaccess,redirect,https,subdomain,.htaccess,Redirect,Https,Subdomain,我需要每个对特定子域的调用。example.com.xx在开头添加www,然后将其重定向到https 目前有一个解决方案,但无法与sub.example.com.xx一起重定向到 如果我输入..,我会得到而不是 即使你必须给我 示例: example.com.xx ---> https://www.example.com.xx http://example.com.xx ---> https://www.example.com.xx https://example.com.xx --
example.com.xx ---> https://www.example.com.xx
http://example.com.xx ---> https://www.example.com.xx
https://example.com.xx ---> https://www.example.com.xx
sub.example.com.xx ---> https://www.sub.example.com.xx
http://sub.example.com.xx ---> https://www.sub.example.com.xx
https://sub.example.com.xx ---> https://www.sub.example.com.xx
other.sub.example.com.xx ---> https://www.other.sub.example.com.xx
http://other.sub.example.com.xx ---> https://www.other.sub.example.com.xx
https://other.sub.example.com.xx ---> https://www.other.sub.example.com.xx
您可以使用:
# redirect to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
# Redirect http to https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
www首先,为了避免双重重定向。我编辑了我的问题。您的上一个示例至少适用于sub.example.com.xx案例。谢谢我必须测试其他案例。
# redirect to www
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
# Redirect http to https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]