were moving the url of a site so we've set up 301 redirects from each page to its equivalent page on the new site. The syntax we are using for this is :
redirect 301 /about-us.html http://newiste.co.uk/about-us.html
what im having trouble working out is how to send the old home page - http://oldsite.co.uk to http://newsite.co.uk - since the home page is at domain.co.uk with out /index.html also there is a similar problem with www. vs non www.
would configuring my .htaccess file on the old domain like this be the proper way to do it ?
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.oldsite\.co\.uk)(:80)? [NC]
RewriteRule ^(.*) http://oldsite.co.uk/$1 [R=301,L]
order deny,allow
redirect 301 / http://newsite.co.uk
redirect 301 /about-us.html http://newsite.co.uk/about-us.html
redirect 301 /contact-us.html http://newsite.co.uk/contact-us.html
redirect 301 /bespoke-furniture.html http://newsite.co.uk/bespoke-furniture.html
redirect 301 /how-we-work.html http://newsite.co.uk/discovery.html
To redirect root document, you can use following rewrite rule:
RewriteRule ^/?$ http://newsite.co.uk/ [R=301,L]
Also a comment to your:
RewriteCond %{HTTP_HOST} ^(www\.oldsite\.co\.uk)(:80)? [NC]
Port number is never part of the HTTP_HOST variable, most efficient is to avoid using regular expressions if possible:
RewriteCond %{HTTP_HOST} =www.oldsite.co.uk [NC]
Your code redirect 301 / http://newsite.co.uk
will redirect everything, not only the root /