在整个站点上启用www + HTTPS

时间:2015-09-08 01:04:05

标签: apache .htaccess ssl https

问题在于,如果我输入https://example.com并且不包含www,则不会添加www。如果我输入http://example.com,它将自行添加www和HTTPS。请看这个代码,非常感谢任何帮助。这就是我的.htaccess文件中的内容。

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]

1 个答案:

答案 0 :(得分:0)

尝试:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} /(acceptoffer|login|register|admin) [NC]
RewriteRule ^ https://www.domain.com/%1 [NC,L,R]