我正在尝试通过.htaccess将http重定向到https 但它在某些地方不起作用!
这是我的域名:www.amirforsati.ir
当我使用像http://www.amirforsati.ir这样的http时,它会重定向到 https
当我使用http://www.amirforsati.ir/want之类的http时,它不会重定向到 https
我的apache .htacces代码是:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^amirforsati\.ir [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.amirforsati.ir/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^136\.243\.80\.209
RewriteRule (.*) https://www.amirforsati.ir/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* ? [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
答案 0 :(得分:1)
你可以试试这个:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^want.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
答案 1 :(得分:0)
要将所有请求重定向到https,我使用以下规则:
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]