Reputation: 4111
I need to setup a couple of redirects on my website. My htaccess file is currently:
RewriteEngine on
RedirectMatch 301 ^/browse/ http://www.mysite.co.uk/designs
Redirect /designs http://www.mysite.co.uk/our-designs
Redirect #1 - I need to redirect all old urls that used to be www.mysite.co.uk/browse/....
to www.mysite.co.uk/designs/....
(designs folder replaces browse folder)
an example being:
http://www.mysite.co.uk/browse/home/kitchens
needs to go too:
http://www.mysite.co.uk/designs/home/kitchens
Redirect #2 - now the second redirect is causing problems. I need to redirect just the page:
http://www.mysite.co.uk/designs
to:
http://www.mysite.co.uk/our-designs
So i use:
Redirect /designs http://www.mysite.co.uk/our-designs
This redirects the /designs
page to our-designs
page correctly but now also changes any url with /designs/
in so from the example above
http://www.mysite.co.uk/designs/home/kitchens
should stay as it is but it changes to:
http://www.mysite.co.uk/our-designs/home/kitchens
which gives me a page not found
Upvotes: 1
Views: 31
Reputation: 785196
Change order of your rules and add a query parameter to prevent further redirection:
RewriteEngine On
RewriteCond %{QUERY_STRING} !^_noredir(&|$) [NC]
RewriteRule ^designs/(.*)$ /our-designs/$1 [R=301,L,NC,NE]
RewriteRule ^browse/(.*)$ /designs/$1?_noredir [R=301,L,NE,NC,QSA]
Upvotes: 0
Reputation: 80639
Use the following rules:
RewriteEngine on
RewriteRule ^browse/(.+)$ /designs/$1 [R=301,L]
RewriteRule ^designs/?$ /our-designs [R=301,L]
You can put the http://www.mysite.co.uk
as a host to rewritten URLs if the hosts are different.
Upvotes: 1