I wanted to get some advice on the following problem as I have confused myself! We have an old domain with many pages www.DOMAIN1.co.uk We want to point all the old pages at www.DOMAIN2.co.uk At the moment we have the standard 301 php page on the index page of DOMAIN1. <?php header("HTTP/1.0 301 Moved Permanently"); header("Location: http://www.DOMAIN2.co.uk/"); ?> If I type in www.DOMAIN1.co.uk I get www.DOMAIN2.co.uk – Great But if I type in www.DOMAIN1.co.uk/shop/validpage.php I get a 404 error. The old site was on a Windows box but will be added in the morning to the same server as DOMAIN2. Will that sort the problem or do I need to change the htaccess file? Eddie
I'm not sure if I understanded the moving part correctly but I think you are moving the site to Apache server. If so you can configure the server so that it always serves pages from DOMAIN2. So no .htaccess changes needed. Only requirement is that the both urls point to the same server.
Actually I just caught that both are on the same server. You do not need the htaccess file since you are using Windows. In IIS, right click on the domain1 and choose properties. In the Home Directory tab, choose a redirection to an URL and make it a permanent redirection. Try that and see if that is it.
Thanks for all the replys I didn’t explain the situation as clearly as I should so here goes again SITE 1 ( Domain 1 ) was hosted on a Windows box. Lots of pages lots of traffic. We then purchased SITE 2 ( Domain 2 ) with a different hosting co on a Apache server. The hosting for SITE 1 has now finished and I have the following option to re-host it in an account that we use for multiply domains ( it’s like our “car park†– Windows shared box lots of space and bandwidth. If we wanted to run the entire site again we could ) Because of this on SITE 1 we have used the above PHP script to redirect to SITE 2, and that works fine. What doesn’t work is that if any of the pages from googles index are called they get a 404 error Example www.site1.co.uk goes to www.site2.co.uk without any problems www.site1.co.uk/shop/anotherproduct.php goes to 404 error Now I can move Site 1 on to the same box as Site 2 and point it at it. Will that solve the problem or is there a script I can add to Site 1 Index.php to catch all pages requested for www.site1.co.uk/%%%%%%%%%%%%%%%%% Again the “Car park†that Site 1 is on is a SHARED windows box and can be moved Site 2 is on a Apache server ( shared )
This will only work for this PHP file. Always use web server's configuration for redirects (e.g. Redirect, RedirectMatch, RewriteRule, etc). J.D.