How To Shorten Your URL’s With HTACCESS

In the world of internet marketing a shorter URL can be an essential asset. Not only do the search engines prefer them but so do your visitors. But how can you make your ugly URL’s look a bit more presentable?The answer is with your .htaccess file. This is a file that sits on your server that you wouldn’t have noticed before if you haven’t been looking for it. The .htaccess file is a configuration file that is placed in the web tree and configures access control on your server.

Ugly links

So what exactly are we trying to do here? Well we are trying to tidy up the links that pass variables. We want to take a link like this:


And turn it into something like this:


Not only does the link look better it also makes it far easier for the search engines to navigate and cache all your pages.

Redirect With HTACCESS

What we are going to do is a 301 redirect. The redirect uses the Apache mod_rewrite module with which you can do all sorts of wonderful things. You can find the official documentation here, and its well worth a read.

For our simple re-write the first thing you need to do is to check if your .htaccess file actually exists. Check in the route of your server, you may need to look at hidden files. If it doesn’t already exist you will need to create it, a text file with no extension and the name   ‘.htaccess’.

Now you have your file set up the first thing to do is to turn the rewrite engine on, place the following in your file:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

Now you have turned the module on and its ready for action. We will re-write the following URL as an example:


In your access file you can add the following re-write rule:

RewriteRule result/(.*)/(.*)/(.*)/(.*)/$ /result.php?$1=$2&$3=$4

And thats it! Your new, search engine friendly URL will now become:


And be sure not to forget the final slash on the end.

Something else you may want to add in there while you are editing is a rule that will redirect your whole site to the ‘www’ version. So if somebody types your site name without the ‘www’ they will automatically be redirected. Add the following rule:

RewriteCond %{HTTP_HOST} ^yoursite.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]

For much more info go to the official apache mod_rewrite page here.

March 15th, 2011


Free Hosting

…Some ISPs offer free web hosting.

Free web hosting is best suited for small sites with low traffic, like personal sites. It is not recommended for high traffic or for real business. Technical support is often limited, and technical options are few.

Very often you cannot use your own domain name at a free site. You have to use a name provided by your host like http://www.freesite.com/users/~yoursite.htm. This is hard to type, hard to remember, and not very professional…

Reseller hosting

designed for those who want to become Web hosts themselves. One gets a large amount of space and bandwidth that can be divided up among as many sites as the user wants to put on his account. A reseller account is placed on the same server with other reseller accounts, just like with shared hosting but there are fewer accounts.

Directory of best web hosting resources!

Apache Help MySQL Tutorials and help pages PHP Tutorials And Help