【发布时间】:2017-08-20 11:14:09
【问题描述】:
我正在尝试通过 .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]
【问题讨论】:
-
stackoverflow.com/a/13000059/3933634 ?
RewriteEngine On-RewriteCond %{HTTPS} off-RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] -
@Liberateur 这是使用 htaccess 将 Https 重定向到 http 的答案
-
是的,请阅读我的回复;)(我在代码中反转帖子)