views:

123

answers:

1

I am trying to create an htaccess file to redirect my entire site except with some exceptions, but I can't get it working. I need to redirect the entire thing, provide a specific redirect, and exclude two pages. Below is my non-working sample. Thanks!

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
+1  A: 

You're attempting to mix mod_rewrite with mod_alias, but the RewriteCond statements cannot condition the Redirect statements, as they don't come from the same module.

I believe you want something more like this, if I've correctly understood what you were 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
Tim Stone
I am trying to accomplish a variation of this - I want to redirect everything, unless the request is in to a specific directory (could be various file types) -- but it is not working:[code]RewriteEngine OnRewriteCond %{REQUEST_URI} !=/sites/default/files/importsRewriteRule ^.*$ http://mynewsite.com/$0 [R=301,L]Redirect 301 / http://mynewsite.com/[/code]
Scott
Try `%{REQUEST_URI} !^/sites/default/files/imports`, as the `!=` only works with exact string comparisons.
Tim Stone