Reputation: 563
I need to redirect the following:
http://olddomain.com/products/* ---> http://shop.newdomain.com/
Except for http://olddomain.com/products/certain-category
So far I can redirect them all:
RedirectMatch 301 /products(.*) http://shop.newdomain.com/
I just need to stop redirecting 'certain-category'??
Something like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond /products(.*) !^/(certain-category)/
RewriteRule (.*) http://shop.newdomain.com/ [L,R=301]
</IfModule>
Although this is redirecting the whole site to http://shop.newdomain.com/
Upvotes: 1
Views: 84
Reputation: 785256
You can use this negative lookahead based rule:
RewriteEngine On
RewriteRule ^products/(?!certain-category).*$ http://shop.newdomain.com/ [NC,L,R=301]
(?!certain-category)
is a negative lookahead that will fail the match if certain-category
comes right after /products/
in URL.
Make sure to clear your browser cache before testing this.
Upvotes: 1