Reputation: 3608
I need to rewrite all files that start with "t" from one directory to another directory.
From /gallery/tXYZ.ext
to /gallery/thumbnails/thumbs_XYZ.ext
I have problem with this RewriteRule:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^gallery/t(.*)$ /gallery/thumbs/thumbs_$1 [R=301,NC,L]
because it catches thumbs
directory again (starts with "t") and forever loop occurs.
Upvotes: 1
Views: 31
Reputation: 785146
Problem is the word thumbs
also matches t*
pattern and caused redirection loop.
Use this rule to fix it:
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_URI} !^/gallery/thumbs/ [NC]
RewriteRule ^gallery/t(.*)$ /gallery/thumbs/thumbs_$1 [R=301,NC,L]
OR else:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^gallery/t(?!humbs/)(.*)$ /gallery/thumbs/thumbs_$1 [R=301,NC,L]
Upvotes: 1