3

I have a problem with my .htaccess configuration on my server. Using a combination of many pieces of advice i have found on here and my own limited knowledge i have put together a .htaccess file that removes the .php extension and removes index. It all seems to work well apart from that I am getting many errors in my logs, such as:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Currently i have the following redirects setup:

www.mydomain.com/index.php > www.mydomain.com

www.mydomain.com/myfile.php > www.mydomain.com/myfile

www.mydomain.com/myfolder/myfile.php > www.mydomain.com/myfolder/myfile

Could anyone check my simple .htaccess file to see if you can spot any problems?

Here is the .htaccess file:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase / 

# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{HTTP_HOST} ^www\.domain\.com
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]

# remove index
RewriteRule (.*)index$ $1 [R=301]

# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]

#unsure of but removes the slashes

RewriteCond %{HTTP_HOST} !=""
RewriteCond %{THE_REQUEST} ^[A-Z]+\s//+(.*)\sHTTP/[0-9.]+$ [OR]
RewriteCond %{THE_REQUEST} ^[A-Z]+\s(.*/)/+\sHTTP/[0-9.]+$
RewriteRule .* http://%{HTTP_HOST}/%1 [R=301,L]

Update:

The Request exceeded the limit of 10 internal redirects problem occurs when i visit: http://www.domain.com/index/index.php?option=com_content&view=article&id=66&Itemid=67

And is fixed if i remove:

# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]

However removing the above makes it impossible to view the pages.

Can anyone spot why this is happening? Many thanks,

Its got something to do with: /index/index.php having index as folder name and file name, i noticed this in my logs this morning.

Update:

Problem is caused by visiting a folder called index with more than 1 recursion depth e.g: domain.com/index/index/index.php this effectively creates a loop. Anyone know how i can stop this?

Jay_53
  • 31
  • 1
  • 1
  • 3
  • Can you give some examples of URLs you're testing with, and what you'd expect them to be rewritten to? – Jeff Olson May 10 '13 at 20:31
  • Thanks for the quick response! This is what my redirects are and they work apart from the pesky loop i seem to have made: # www.mydomain.com/index.php > www.mydomain.com # www.mydomain.com/myfile.php > www.mydomain.com/myfile # www.mydomain.com/myfolder/myfile.php > www.mydomain.com/myfolder/myfile – Jay_53 May 10 '13 at 20:41
  • It might make it easier to read if you added your examples to the original question. That said, I am not sure what the problem is with your rules. – Jeff Olson May 10 '13 at 21:36
  • Thanks Jeff, i have added them to my original question. Yes it seems strange that it exceeds the limit of 10 internal redirects. Is it ok to have [L] twice? Since i have it for 2 of my rules above. both [L] and [R=301,L] – Jay_53 May 10 '13 at 21:47
  • I had the same error, moving it out the application root or in htdocs folder solved the issue for me. – Rashmi Jain May 10 '17 at 07:17

0 Answers0