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?