Forum Moderators: phranque

Message Too Old, No Replies

Redirects - how to keep it SEF

How to redirect traffic from the root to a sub-dir

         

badass101

12:59 am on Mar 24, 2005 (gmt 0)

10+ Year Member



Hi,

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

encyclo

1:35 am on Mar 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the root folder, create an index.php with the following contents:

<?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.

badass101

9:59 am on Mar 24, 2005 (gmt 0)

10+ Year Member



Excellent - thank you!

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?