Cleaning Up Your URL Query String using Rewrite EngineBy John Kim | September 6th, 2009 |
Search Engine Optimization is a huge industry where companies get paid millions of dollars to boost their rankings to the top of Google. Now this article will not try to explain all the little tricks to achieve a higher search rank, but one way to improve the likelihood of having better SEO would be to clean up your damn URL.
If you are hosted onto an apache server then please continue, otherwise this information would be complete and utter garbage to you.
So how can you clean up a url that looks like this:
/certificate.php?folder=men&sort=date&order=desc&page=1
To a url that looks like this:
/certificate/men/date/desc/1/
.htaccess’s Rewrite Engine is the key
Now to keep things short and sweet, a .htaccess file allows a developer to control server functionality, and one of these functionality would happen to be the Rewrite Engine. The Rewrite Engine allows you to change your fugly url’s into a very sexy looking url that is easy on the eyes.
What you would first have to do is open up notepad or any text editing tool and write this code into it
RewriteEngine on
RewriteRule ^certificate/(\w+)/(\w+)/(\w+)/(\w+)/$ /certificate.php?folder=$1&sort=$2&order=$3&page=$4 [nc]
Before saving you should understand how this file works.
These two lines of code is basically saying to turn on the rewrite engine, and should be included anytime you want to use rewrite engine.
RewriteEngine on
dissecting the RewriteRule
There are four parts to the last line.
The red code is just the name of the function you are using called the RewriteRule, the blue code is the url pattern you want the server to watch out for, the green code is the real url you want the server to reference to, and the orange code is for options you want to set. In this case the option means no-case meaning the RewriteRule is case insensitive.
Now because I don’t want this to be a lesson about Regular Expression I’ve created a simple diagram to explain what is going on.

So as you can see, I’ve color coded the relationships. It’s also important to note that (\w+) means that you can place any character within there. So it basically means that if I type in a url with the pattern of:
http://domain.com/certificate/any character 1/any character 2/any character 3/any character 4/
the server will translate this to a real url that looks like this
http://domain.com/certificate.php?folder=any character 1&sort=any character 2&order=any character 3&page=any character 4
Conclusions
Save your new .htaccess file and place it into the web root folder on your server. But watch out yahoo web hosting users, because Yahoo Web Hosting has disabled this functionality. Those Bastards!!!
But the end result should leave you with a clean, easy to read url that search engines will looooooove to death. Except for Yahoo, Those Bastards!!!
Please share any Rewrite Engine tips if you have any, I’m sure mine is just 1 in a million.
More from Curiosity Media
- How to Install Apache Solr on Windows XP
- RedirectMatch, The Smart Way to 301 Redirect
- Photoshop is Now the New Reality
- My Bootleg Power 90 Program Part 1
- Ricoh GXR launches a revolutionary Camera
Curiosity Media Recommends
- 10 Ways To Increase Traffic To Your Blog (Brandon Hann)
- How to SEO your Blog Titles (The Arkayne Blog)
- Using Microsoft Tags on your business cards (Brandon Hann)
|
Add this to your blog: (Copy & paste code) |



![Recommend [curiositymedia]](http://s3.amazonaws.com/arkayne-media/img/badge/logo-recommend-badge-medium.png)
November 14th, 2009 at 5:55 am
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^post/(\w+)/$ display.php?id=$1 [nc]
would that work?
November 16th, 2009 at 12:45 pm
yes, that looks like it would work. Test it out, but make sure you are on an apache server. Also some hosting companies like yahoo, and godaddy wouldn’t allow the rewrite, or make it very difficult to rewrite. I suggest you avoid those two hosting companies. let, me know how the rewrite went for you.