我有以下htaccess重写规则
rule1导致无限循环错误。我正在尝试将所有请求重定向到HTTPS,但它无法正常工作。
由于rule1,rule2也被阻止。当我对rule1发表评论时,一切都很好。
如果我改变顺序,也会发生这种无限循环错误。
请帮我解决此错误
RewriteEngine On
RewriteBase /
#Rule 1: Rewrite all the requests to HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
//Rule 2: redirect to the account closed setup
RewriteRule ^(?:abcd)/A-Report/(.+)$ /closed/$1 [NC,L]
提前致谢。
答案 0 :(得分:1)
基于此question。
RewriteEngine on
# Check for POST Submission |
# Because POST parameters aren't retained on a redirect.
# You can omit that line if you want to make sure that all POST submissions are secure
# (any unsecured POST submissions will be ignored)
RewriteCond %{REQUEST_METHOD} !^POST$
# Forcing HTTPS
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{SERVER_PORT} 80
# Pages to Apply
RewriteCond %{REQUEST_URI} ^something_secure [OR]
RewriteCond %{REQUEST_URI} ^something_else_secure
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]