Reputation: 3739
I want to redirect all the files that end with .html to a the old site folder, currently my htaccess looks as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# RedirectMatch 302 /(.+?).html$ http://superawesomedomain.com/old/$1.html [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
But with my condition RedirectMatch 302
when I apply it gets to http://superawesomedomain.com/old/old/old/old/old/old...old/old/old...old/old/old/ until it breaks the browser :(
Any ideas on how to make the redirection?
Thank you!
Upvotes: 1
Views: 39
Reputation: 785276
You can use these rules:
RewriteEngine On
RewriteBase /
RewriteRule ^((?!old/).+?\.html)$ /old/$1 [L,NC,R=302]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
RedirectMatch
with other mod_rewrite
rules/old/
to stop redirection loopUpvotes: 1