我最近从一个Windows服务器切换到godaddy,linux,cpanel服务器。我不是用htaccess的goos,我认为这应该是一个相当简单的事情,但我无法做到。htaccess - 重定向非www到https与www
我的SSL证书已设置为在此类网站上工作,如https:www.mydomain.com,但不适用于(非www网站)。
我想所有的流量来为https:example.com/any-folder/any-file重定向到https:www.example.com/any-folder/any-file
所有流量来http:example.com/any-folder/any-file重定向到http:www.example.com/any-folder/any-file
感谢您提供任何帮助。 这是我的htaccess文件现在:(所有的请求都被重定向到https ....我很困惑)
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
的[重定向到HTTP非www到HTTPS WWW的htaccess]可能重复(http://stackoverflow.com/questions/17453412/redirect-to -http-non-www-to-https-www-htaccess) – Sumurai8
我尝试了可能的重复,但是所有的url重定向到https。这里是我试过的whaty: 'RewriteEngine On' 'RewriteCond%{HTTP_HOST}!^ www \。 [*] 'RewriteRule ^(。*)$ http://www.domain.com/$1 [L,R = 301]' 'RewriteCond%{HTTPS} off' 'RewriteRule ^(。*) $ https://www.domain.com/$1 [L,R = 301]' – Tom
正如您所看到的,评论中的代码并不真正起作用。相反,编辑问题,如果您有其他信息;-) – Sumurai8