Forum Moderators: phranque
The last rule I think is the one at issue:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Redirect all direct requests for URLs including the foldername to non-folder URLs at www.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /subdir.*\ HTTP/
RewriteRule ^subdir/(.*)$ http://www.example.com/$1 [R=301,L]
# Redirect all non-www to www and preserve folder and file path.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Rewrite non-folder URLs (which are all www by now) to folder filepath.
RewriteCond %{THE_REQUEST} !(subdir)
RewriteRule ^(.*)$ /subdir/$1 [L]
</IfModule>
causes recursion to kick in. Then once Apache hits its internal limit of 10 redirects, it sends error 500.
So, how can I stop the recursion here? Any assistance would be appreciated.
Here is some of my rewrite log:
/public_html/] strip per-dir prefix: C:/public_html/ ->
/public_html/] applying pattern '^subdir/(.*)$' to uri ''
/public_html/] strip per-dir prefix: C:/public_html/ ->
/public_html/] applying pattern '^(.*)$' to uri ''
/public_html/] RewriteCond: input='www.example.com' pattern='^example\.com' [NC] => not-matched
/public_html/] strip per-dir prefix: C:/public_html/ ->
/public_html/] applying pattern '^(.*)$' to uri ''
/public_html/] RewriteCond: input='GET / HTTP/1.1' pattern='!(subdir)' => matched
/public_html/] rewrite '' -> '/subdir/'
/public_html/] trying to replace prefix C:/public_html/ with /
/public_html/] internal redirect with /subdir/ [INTERNAL REDIRECT]
and then it does it again...
erdir C:/public_html/] strip per-dir prefix: C:/public_html/subdir/ -> subdir/
erdir C:/public_html/] applying pattern '^subdir/(.*)$' to uri 'subdir/'
erdir C:/public_html/] RewriteCond: input='GET / HTTP/1.1' pattern='^[A-Z]{3,9}\ /subdir.*\ HTTP/' => not-matched
erdir C:/public_html/] strip per-dir prefix: C:/public_html/subdir/ -> subdir/
erdir C:/public_html/] applying pattern '^(.*)$' to uri 'subdir/'
erdir C:/public_html/] RewriteCond: input='www.example.com' pattern='^example\.com' [NC] => not-matched
erdir C:/public_html/] strip per-dir prefix: C:/public_html/subdir/ -> subdir/
erdir C:/public_html/] applying pattern '^(.*)$' to uri 'subdir/'
erdir C:/public_html/] RewriteCond: input='GET / HTTP/1.1' pattern='!(subdir)' => matched
erdir C:/public_html/] rewrite 'subdir/' -> '/subdir/subdir/'
erdir C:/public_html/] trying to replace prefix C:/public_html/ with /
erdir C:/public_html/] internal redirect with /subdir/subdir/ [INTERNAL REDIRECT]
and so it grows.....
Thank you
Mark