All websites now use URL extensions that redirect for easy to remember URLs.
A recent example is Google’s http://google.com/pacman – a simple / and one word is much easier to remember than say /google_pacman.html (which is still keeping it simple!)
(I’m sure if you looked into it, the files aren’t actually stored in a /pacman folder either ;))
There are URL shortening methods out there, such as http://bit.ly and http://tiny.cc, but I feel these don’t give you enough power for customisation. And what if you have your own domain that you want to use?!
I’ve made my own simple ‘Redirect Setup Script’ that enables you to create redirects with the click of a button.
You can view a demo here: http://patjack.co.uk/newurls (note this doesn’t actually set up any redirects on my site 🙂 ) and see how easy it is.
My method uses PHP that appends the redirect to your root .htaccess file, and uses mod_rewrite. An alternative method would be to use a meta redirect, which I’ve included in the downloadable folder for those that might not have mod_rewrite on their servers. The downside to the meta redirect is that you need to actually create the folder and index.html file, the .htaccess method just uses the root .htaccess file.
To swap between using the .htaccess mod_rewrite method and the meta re-direct method, just open up ‘process.php’ and change the $use_htaccess from TRUE to FALSE.
The script also uses REGEX to make sure you don’t use some silly extension, or input an invalid URL.
To use, just download the folder from here
A quick example
I’ve set up a redirect for when I have a chocolate cake craving but don’t want to bake a whole cake. To see my secret, click through to http://patjack.co.uk/cake. Mmmmm…
Download: Script.zip
Here’s what gets appended to your root .htaccess and the index.html files respectively
.htaccess
RedirectMatch /".$_YOUR_EXTENSION."/.* ".$_URL_GOES_HERE." [R=301,L]
RedirectMatch /".$_YOUR_EXTENSION." ".$_URL_GOES_HERE." [R=301,L]";
There’s a need for two redirects to catch both cases where you may browse to example.com/extension (with no slash) example.com/extension/ (with a slash) or anything else – example.com/extension/index.html
index.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Redirect</title>
<meta http-equiv="refresh" content="0;URL=$_URL_GOES_HERE" />
</head>
<body>
</body>
</html>