Report this

What is the reason for this report?

Redirect loop on server for no apparent reason

Posted on June 22, 2016

Hi all,

I have a droplet that seems to be stuck in a redirect loop for no apparent reason. My client wanted all traffic to point to a www address rather than the non www address which was fine until I tried to do the redirect using my apache config.

Redirect permanent / http://www.mysite.com/

After adding that line to the config and reloading apache it made the page return a redirect loop. I promptly removed this from the file and restarted apache but still a loop appears. I delved further into the problem and found these lines in my .htaccess file:

<IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteCond %{SERVER_ADDR} !=127.0.0.1
    RewriteCond %{SERVER_ADDR} !=::1
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>

I also removed these from the file and still there was a loop. I created a new htaccess file that doesnt contain these lines at all and still there is a loop. I cannot see any configuration anywhere that will be causing a redirect. Is there anywhere I can look on the server to find more information about it or something I am missing that jumps out to anyone. The site in question is just hand built php so not running on wordpress or any kind of CMS.

It was setup before I started working on it so there may be things that I have missed but I know that it is running PHP5-FPM and Apache2.

Any help or advice would be greatly appreciated.

Thanks,

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.