我有以下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]
提前致谢.
解决方法:
基于此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]