Reputation: 7
I need to create a .htaccess redirect file that redirects all traffic from an old domain (olddomain.com/feedback/) to a new domain (newdomain.com). However i do not want traffic to redirect traffic to olddomain.com/feedback/form/customer-feedback/ and wish for that to still go to the original destination.
Here is what i have created to date.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/feedback/form/customer-feedback
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Upvotes: 0
Views: 199
Reputation: 785146
You can use this rule in old server's root .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
RewriteRule ^feedback/?$ http://www.newdomain.com/$1 [R=301,NC,L]
Upvotes: 0
Reputation: 29463
Almost perfect.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^feedback/form/customer-feedback
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
On the second line, I have removed the slash immediately preceding feedback/
.
When you compose mod_rewrite
directives, whatever follows the start-of-match indicator ^
is what comes after the immediately preceding slash in the URI.
Upvotes: 1