将 http 重定向到 https ubuntu/apache



我正在尝试重定向到 https,并且相当确定我正确地编写了我的 htaccess,但由于某种原因它没有重定向。任何帮助都非常感谢。

#
RewriteEngine on

#### TJOSELFSTORAGE ####
RewriteCond %{ENV:CARET_ENV} live [NC]
RewriteCond %{HTTP_HOST} !^www.tjoselfstorage.com$ [NC]
RewriteCond %{HTTP_HOST} ((.*).(org|net|com)|(.*).(.*).(org|net|com)|[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}) [NC]
RewriteRule ^(.*)$ https://www.tjoselfstorage.com/$1 [R,L]

RewriteRule (^/images.*) https://www.tjoselfstorage.com? [R=301,L]

RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !__^.php
RewriteRule ^(.*)/$ /$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !resources
RewriteCond %{REQUEST_FILENAME} !__^.php
RewriteRule (.*) __^.php/$0 [L

]

这是直接从 Apache 文档中将 http 重定向到 https 的首选方法:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

最新更新