Htaccess works fine on one server and triggers a redirect loop on another

I have a htaccess file (code below) using the same on two servers with a domain name change. It works fine on one, but poses a redirection problem on the other. The only difference is that on one server I am using the domain name and on the other I am using a dedicated IP

Code:

WORKING CODE:

RewriteEngine on

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch

##below 7 lines used in live server 
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
RewriteRule ^admin/$ admin/index.php
RewriteRule ^$ home/ [R]
RewriteRule ^home/$ page/index.php [L]
RewriteRule ^blog/$ blog/index.php [L]
RewriteRule ^forms/$ site-forms/index.php [L]
RewriteRule ^media/xmlfeeds/$ page/index.php
RewriteRule ^([a-z]+)(\/?)$ page/index.php [NC,QSA,L]

      

NOT WORKING CODE:

RewriteEngine on

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch

##below 7 lines used in live server 
RewriteBase /
RewriteCond %{HTTP_HOST} ^108\.175\.155\.54
RewriteRule ^(.*)$ http://108.175.155.54/$1 [R=permanent,L]
RewriteRule ^admin/$ admin/index.php
RewriteRule ^$ home/ [R]
RewriteRule ^home/$ page/index.php [L]
RewriteRule ^blog/$ blog/index.php [L]
RewriteRule ^forms/$ site-forms/index.php [L]
RewriteRule ^media/xmlfeeds/$ page/index.php
RewriteRule ^([a-z]+)(\/?)$ page/index.php [NC,QSA,L]

      

Thank.

+3


source to share


1 answer


The loop is called by the following two lines:

RewriteCond %{HTTP_HOST} ^108\.175\.155\.54
RewriteRule ^(.*)$ http://108.175.155.54/$1 [R=permanent,L]

      



They say, "If the host is 108.175.155.54, then redirect it to 108.175.155.54."

So, comment these lines on the real server. Once you have a domain name, you can uncomment them and use the domain instead.

+2


source







All Articles