我正在尝试重定向
example.com到www.example.com 和 http://example.come至https://www.example.com
但是,如果用户键入
admin.example.com,http://admin.example.com或https://admin.example.com 它不应重定向到www.admin.example.com
我可以使用什么.htaccess?
答案 0 :(得分:0)
您可以在网站根目录.htaccess中使用此规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(example\.com)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]