Ok, so I am trying to write a 301 redirect with apache mod rewrite, here’s what I have:
## 301 Redirects
# 301 Redirect 1
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ http://www.purplewidgets.net$1 [R=301,NE,NC,L]
RewriteRule ^uk-widgets(.*)$ http://uk.purplewidgets.net$1 [R=301,NE,NC,L]
RewriteRule ^ireland-widgets(.*)$ http://ireland.purplewidgets.net$1 [R=301,NE,NC,L]
RewriteRule ^about-purple-widgets(.*)$ http://www.purplewidgets.net/about-purple-widgets$1 [R=301,NE,NC,L]
RewriteRule ^widgets-search(.*)$ http://www.purplewidgets.net/widgets-search$1 [R=301,NE,NC,L]
RewriteRule ^contact-purple-widgets(.*)$ http://www.purplewidgets.net/contact-purple-widgets$1 [R=301,NE,NC,L]
RewriteRule ^site-map(.*)$ http://www.purplewidgets.net/site-map$1 [R=301,NE,NC,L]
This ‘sort of’ works, however if I enter current URL without a trailing /, it the redirect doesn’t work correctly, for example:
http://www.currentsite.co.uk/uk-widgets goes to http://www.purplewidgets.net/uk-widgets - it should go to the specified subdomain on the new site.
Conversely, if I do enter a trailing slash it goes to a URL with a double slash, e.g:
http://www.currentsite.co.uk/uk-widgets goes to http://uk.purplewidgets.net//
–
What am I doing wrong?
P.S, I’m not very technical so I’ve had to pull this together from the bits and pieces I could find on the net.
Thanks!