It happens. You create a page buried deep in your directories like http://www.yoursite.com/data/new/articles/automobiles/new/ford.php – makes an okay link to click on but a little difficult to share in a print or broadcast ad. If, instead, you could have http://yoursite.com/ford you’d probably increase your sales.
This tip can be accomplished a few different ways depending on your available applications, server configuration and perhaps even operating system. This article assumes you are familiar with FTP and are hosting your website on a Linux machine with Apache. If so this is simple and quick.
FTP to your www (public_html) directory or whatever your web document root folder is called.
Locate the .htaccess file. If one does not exist you’re make one in any editor that can save in plain text.
Make a backup copy of your existing .htaccess file.
Insert the following lines of code at the top of your .htaccess file
#long URL redirect RewriteRule ^ford$ http://www.yoursite.com/new/ford.php [NC,L]
The .htaccess file tells the Apache server how to act. When it is in the document root folder it runs before anything else happens. In this case when the browser requests http://www.yoursite.com/ford the .htaccess file sees that and rewrites it to http://www.yoursite.com/data/new/articles/automobiles/new/ford.php through the RewriteRule – a server level command.
Break it down
The RewriteRule reads the input from the browser and rewrites it to whatever you designate. You can point a local address to an offsite address. For example you could Rewrite http://yoursite.com/search to go to http://google.com/
The caret ^ is shorthand for http://yoursite.com/ (the directory the .htaccess file resides in)
The dollar sign $ tells Apache this is the end of the term to look for. It won’t look for (in this case) fords, fordy or even ford.
After the target URL are two directives NC and L. The NC tells Apache to ignore text case. This means ford, FORD, Ford or FoRd will all rewrite to your target URL. The L means Last. This stops the .htaccess process and immediately sends the browser on its way.