title: Apache .htaccess: Request exceeded the limit of 10 internal redirects due to probable configuration error
body: <p>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 <code>.php</code> extension and removes <code>index</code>. It all seems to work well apart from that I am getting many errors in my logs, such as:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>Currently i have the following redirects setup:</p>
  
  <p>www.mydomain.com/index.php > www.mydomain.com</p>
  
  <p>www.mydomain.com/myfile.php > www.mydomain.com/myfile</p>
  
  <p>www.mydomain.com/myfolder/myfile.php > www.mydomain.com/myfolder/myfile</p>
  
  <p>Could anyone check my simple .htaccess file to see if you can spot any problems?</p>
  
  <p>Here is the .htaccess file:</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>Update:</p>
  
  <p>The Request exceeded the limit of 10 internal redirects problem occurs when i visit:  <a href="http://www.domain.com/index/index.php?option=com_content&amp;view=article&amp;id=66&amp;Itemid=67" rel="nofollow">http://www.domain.com/index/index.php?option=com_content&amp;view=article&amp;id=66&amp;Itemid=67</a></p>
  
  <p>And is fixed if i remove:</p>
  
  <pre><code># add .php to access file, but don't redirect
  RewriteCond %{REQUEST_FILENAME}.php -f
  RewriteCond %{REQUEST_URI} !/$
  RewriteRule (.*) $1\.php [L]
  </code></pre>
  
  <p>However removing the above makes it impossible to view the pages.</p>
  
  <p>Can anyone spot why this is happening? Many thanks,</p>
  
  <p>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.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>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?</p>