Forum Moderators: phranque
I have a site that is being developed with a shop on /shop.
When the site goes live I'd like traffic to go straight to /shop (well, /shop/index.php to be exact)
What's the best way to do this?
Is it a server side redirect, or a default html document on / that redirects instantly (using Javascript) to the correct URL?
I have thought about moving the shop from /shop to / but I'm wary of breaking a working system....
Thanks,
Craig
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ./shop/");
exit;
?> That should fix it. Don't forget that search engines usually can't follow Javascript links, and nor can users with JS disabled. You also need to ensure that you are using a permanent redirect, which the above code does.
Sorry, when I said javascript I meant have an auto redirect with Javascript, but with a bit of text saying 'if you're not forwarded then please click here'
But your solution is neater!
Can I do this using a redirect in .htaccess to save even having to load a PHP file?
Or is that not as good?