Damn, it’s been ages since i’ve posted. This is a tiny one that is simple yet very useful.
The Situation
I have a Napkee site that consists of a bunch of html files linked together. This was naturally created from a set of Balsamiq screens. Within these Balsamiq screens was a screen called ‘Homepage’ (not index, because that would have been machine friendly but user unfriendly). So, on Napkee export, no index.html file had been created, which is just messy when sending out links to the Napkee screens because i didn’t want to include Homepage.html in the link.
The Need
I wanted to redirect all requests for http://www.website.com/napkee_mockup to http://www.website.com/napkee_mockup/Homepage.html
The Options
- [Bad] An error page: Not an option so i’ll say no more about it.
- [Bad] A Meta Refresh, where the following code is added to the Meta tags within the file Head. Again this was not an option as it gives the redirect task to the end user’s browser.
<META HTTP-EQUIV=”refresh” content=”0;URL=http://www.new.com/new.htm”>
<META NAME=”ROBOTS” CONTENT=”NOINDEX, NOFOLLOW”>
- [Bad] JavaScript Refresh: Too ugly to even paste the code in here, so i won’t bother. This is again bad because you’re forcing the user to not only do the redirecting for you, but you’re also demanding that they use JavaScript to do it. Not very friendly.
- [Good] .htaccess redirect: This is the only correct way to do it.
The Solution
cd [www]/napkee_mockup
vim .htaccess
add the following:
redirect 301 /napkee_mockup/index.html http://website.com/napkee_mockup/Homepage.html
I hope this helps a little.
There’s more good reading at http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm