1

I have this following htaccess rewrite rules

The rule1 is causing the infinite loop error. I am trying to redirect all the request to HTTPS but it's not working.

Because of the rule1 the rule2 is also blocked. When I comment on rule1 everything is fine.

If I change the order also this infinite loop error occurs.

Please help me how to resolve this error

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]

Thanks in advance.

Sundar
  • 4,580
  • 6
  • 35
  • 61

1 Answers1

1

Based on this 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]
Community
  • 1
  • 1
pomaxa
  • 1,740
  • 16
  • 26