Reputation: 1966
Id like to use the .htaccess
file on an apache servier redirect all paths on a given domain to a new location but keep a few specific URLs live.
Redirect 301 /(.*) www.example.com
# but not /foo
# but not /bar
# but not /baz
Upvotes: 2
Views: 1491
Reputation: 785156
You cannot do it using Redirect
directive. I suggest using mod_rewrite
:
RewriteEngine On
RewriteCond %{THE_REQUEST} !/(?:foo|bar|baz)[?/\s] [NC]
RewriteRule ^ http://www.example.com%{REQUEST_URI} [L,NE,R=301]
THE_REQUEST
variable represents original request received by Apache from your browser and it doesn't get overwritten after execution of other rewrite directives. Example value of this variable is GET /index.php?id=123 HTTP/1.1
Upvotes: 2