Jump to content
WebFlake
  • 0

Mod_Rewrite Causing Redirect Loop


Tony

Question

  • Administrator

Alright ladies and gents.. I'm stumped.
 
I currently have some mod_rewrite rules setup in my hosting root's .htaccess file to remove www. from domains as well as remove the .html extension from html pages. Here is a copy of the .htaccess contents:
 

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]

Disabling the .htaccess fixes the redirect error, but obviously I can't disable the file as it'd effect other domains. Interestingly enough, two other IPB installations work just fine with or without this .htaccess file enabled. All three installations (including the one with the redirect loop) are using v3.4.6.

As a side note, if anyone is wondering why I am using the .htaccess file in just the hosting root, the answer is simple: it "trickles" down to all other domains. For example:

  • root (with .htaccess)
    • Domain 1 (doesn't work)
    • Domain 2 (works)
    • Domain 3 (works)

 

Any advice from some of our resident experts?

  • Upvote 2
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

try simplify the process

 

RewriteCond %{HTTP_HOST}  site1.com$ [NC]
RewriteCond %{REQUEST_URI} !^/vhosts/site1/.*$
RewriteRule ^(.*)$  /vhosts/site1/$1 [L]
 
RewriteCond %{HTTP_HOST}  site2.com$ [NC]
RewriteCond %{REQUEST_URI} !^/vhosts/site2/.*$
RewriteRule ^(.*)$  /vhosts/site2/$1 [L]
 
substituting your own variables/subdomains etc
Link to comment
Share on other sites

  • 0
  • Administrator

As it turns out, it was much more a problem with IPB than it was the rewrite rules. I've been working around the clock for the last 48 hours to transfer from one hosting platform to a new cPanel platform, so I'm not surprised I missed it.

 

Fix:

 

Ensure that you don't have www. in your board URL within the conf_global file. This will create an infinite redirect loop when attempting to remove the www. prefix from domains via .htaccess mod_rewrite.


The question(s) in this support topic have been answered and the owner has been able to solve the problem. Because of this, the support topic has been closed and moved.

If you have other questions, please open a new topic.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...