Htaccess 301 redirects the entire site, but with exceptions

I am trying to create an htaccess file to redirect my entire site, with a few exceptions, but I cannot get it to work. I need to redirect all this, provide a specific redirect and exclude two pages. Below is my non-working pattern. Thank!

RewriteCond %{REQUEST_URI} !^/events/index.html
RewriteCond %{REQUEST_URI} !^/calendar/index.html
Redirect 301 /info/faq.html http://mynewsite.com/my-page
Redirect 301 / http://mynewsite.com
+5
source share
2 answers

You are trying to mix mod_rewritewith mod_alias, but statements RewriteCondcannot expose statements Redirectsince they do not come from the same module.

I believe you need something similar if I understood correctly what you are trying to accomplish:

RewriteEngine On

RewriteCond %{REQUEST_URI} !=/events/index.html
RewriteCond %{REQUEST_URI} !=/calendar/index.html
RewriteCond %{REQUEST_URI} !=/info/faq.html
RewriteRule ^.*$ http://mynewsite.com/$0 [R=301,L]

Redirect 301 /info/faq.html http://mynewsite.com/my-page
+14

. , robots.txt. ,

RewriteEngine On
RewriteRule robots.txt - [L]
RewriteRule ^.*$ http://www.newsite.com/$0 [R=301,L]
+3

All Articles