How do I phrase a 301 redirect that is effectively 'anything else'? In other words I have a specific list of pages to redirect but I simply want anything that is not specifically redirected to go to the home page
CodePudding user response:
The line: RewriteCond %{REQUEST_URI} !/$
stops the infinite redirect loop from root to root.
RedirectMatch 301 ^pag1.html$ /new_pag1.html
RedirectMatch 301 ^pag2.html$ /new_pag2.html
RewriteEngine On
RewriteCond %{REQUEST_URI} !/pag1.html$
RewriteCond %{REQUEST_URI} !/new_pag1.html$
RewriteCond %{REQUEST_URI} !/pag2.html$
RewriteCond %{REQUEST_URI} !/new_pag2.html$
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^(.*)$ / [R=301,L]