Reputation: 537
My rule looks like this:
RewriteRule ^page-parent.*$ http://www.domain.com/new-page/?%{QUERY_STRING} [R=301,L]
My issue is that there is a page /page-parent/thanks that I don't want to be redirect.
I am also passing the query string along so that any ?gclid= string will go with.
I can't for the life of me figure out how to exclude a single sub page or all sub pages, which would work too.
Any help is appreciated.
Upvotes: 1
Views: 658
Reputation: 33904
You can check with a RewriteCond
if the requested page is the page you want to exclude.
RewriteCond %{REQUEST_URI} !^/page-parent/thanks
RewriteRule ^page-parent.*$ http://www.domain.com/new-page/ [R=301,L,QSA]
Make sure that you clean the browser cache when retrying since 301-redirects get cached.
Note: You don't need to append the query string manually.
Upvotes: 1
Reputation: 143896
You can use mod_rewrite to create a condition:
RewriteCond %{REQUEST_URI} !^/page-parent/thanks
RewriteRule ^page-parent.*$ http://www.domain.com/new-page/ [R=301,L]
Note that you can leave out the ?%{QUERY_STRING}
from your target, because query strings are appended to the target by default unless you've added new params via a ?.
Upvotes: 0