Https和htaccess

时间:2015-10-07 14:02:06

标签: .htaccess mod-rewrite https url-redirection

我尝试将所有http网址重定向到https。 我很难挣扎,因为我需要保留目前的重定向:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html?user=$1 [L,QSA]

您能否帮我修改此代码以包含de https重定向。感谢

1 个答案:

答案 0 :(得分:0)

使用以下规则:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html?user=$1 [L,QSA]