如果您访问Non HTTPS version,则不会重定向到HTTPS版本。相反,它看起来像https://www.www.mywebsite.com并且不起作用。这是我的htaccess文件中的代码。
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,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]
答案 0 :(得分:1)
删除www。从这一行:
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
或者你可以这样做:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R=301,L]