我需要组合重定向来实现以下目标:
将http://example.com重定向到http://www.example.com,同时将https://www.example.com重定向到https://example.com。
当通过http访问站点时,我想强制www前缀做域名。
但是,SSL证书只有在没有www的情况下才有效。
当通过https访问时,我不希望域名带有www前缀。
发布于 2012-05-24 02:14:54
将以下内容放在非HTTPS文档根目录下的.htaccess文件中:
RewriteCond %{HTTP_HOST} ^mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R]在您的HTTPS文档根目录中:
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www.mysite.com$
RewriteRule ^(.*)$ https://mysite.com/$1 [R]https://stackoverflow.com/questions/10725357
复制相似问题