我已经在我的网站上安装了一个SSL,我有一个.htaccess文件,其中已经写入了一些条件。我已经查看了许多在网上展示的如何强制使用https的方法。然而,它们似乎都不起作用。我一直有断了的联系。
当前使用的代码,注释掉的规则不适用于https
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /
#This condition doesn't seem to work
#RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect non www. to www.
#RewriteCond %{HTTP_HOST} !^www\.MYWEBSITE\.co\.uk
#RewriteRule (.*) http://www.MYWEBSITE.co.uk/$1 [R=301,L]
# Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1? [R=301,L]
# Remove .php ONLY if requested directly
RewriteCond %{THE_REQUEST} (\.php)
RewriteRule ^(.+)\.php /$1 [R=301,L,QSA]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php发布于 2018-01-16 12:06:40
如果要强制使用HTTPS,可以使用以下方法:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]https://stackoverflow.com/questions/48280833
复制相似问题