Adiv J.
Adiv J.

Reputation: 23

Solution to ERR_TOO_MANY_REDIRECTS error

I have searched stackoverflow thoroughly but could not find any solution to this error that i have been receiving.

Information:

  1. I am using redirects only in .htaccess and there are no active html redirects in my webpages.
  2. I am using .htaccess to redirect default.php to root, non-www to www, error page 404.php, cache control & gzip the files. (My htaccess contents are given below).

Error:

  1. I typed in a wrong url to test the 404 redirect and received a display ERR_TOO_MANY_REDIRECTS. I tried clearing browser cache and also researched on stackoverflow to debug my htaccess codes but got no solutions as of yet.

Help Required:

  1. I would request the stackoverflow members to help me solve this error, for reference i am posting my htaccess code below.

HTACCESS:

<Ifmodule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteBase /

### re-direct default.php to root / ###
RewriteCond %{THE_REQUEST} ^.*\/default\.php\ HTTP/
RewriteRule ^(.*)default\.php$ /$1 [R=301,L]

### re-direct non-www to www of main domain
RewriteCond %{http_host} ^bookkeralatourpackage\.in$ [nc]
RewriteRule ^(.*)$ http://www.bookkeralatourpackage.in/$1 [r=301,nc,L]

#### Rule for Error Page - 404 ####
ErrorDocument 404 http://bookkeralatourpackage.in/404.php
</Ifmodule>

<ifModule mod_headers.c>
Header set Connection keep-alive
ExpiresActive On

# Expires after 1 month
<filesMatch ".(gif|png|jpg|jpeg|ico|pdf|js|htm|html|txt)$">
Header set Cache-Control "max-age=2592000"
</filesMatch>

# Expires after 1 day
<filesMatch ".(css)$">
Header set Cache-Control "max-age=86400"
</filesMatch>
</ifModule>

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

Let me know where i have gone wrong and also in case if any other detail would be required to solve this error.

Upvotes: 2

Views: 3928

Answers (1)

zx81
zx81

Reputation: 41848

  • The most obvious problem is that the error document does not have www. This means that after redirecting to http://bookkeralatourpackage.in/404.php, the www redirect will have to be applied. Change it to:

    ErrorDocument 404 http://www.bookkeralatourpackage.in/404.php
    
  • The next possible problem would be if the 404.php file doesn't exist: you will enter a chain of redirects. So please do check if http://www.bookkeralatourpackage.in/404.php exists.

  • I am not entire sure the RewriteCond %{THE_REQUEST} ^.*\/default\.php\ HTTP/ line is needed. The rule might work without it.

Please let us know if any of this works.

Upvotes: 3

Related Questions