|
There are plenty of tutorials and articles showing how to use the apache mod_rewrite module to tidy up messy URLs can create nice, human readable, search engine friendly URLs. No problem there and if that is what you are looking for you wont find that here.uveFree Articles Directory | Hostsee.com What you will have more trouble finding is a tutorial (other than this one right here) showing you how to remove a query string from a URL. I guess this is a less popular topic but... nevertheless, with something as cryptic as mod_rewrite and URL rewriting the seemingly simple can take an age without solid advice so this tutorial will cover the reasons why you may want to do this along with the simplest and cleanest of solutions.uveFree Articles Directory | Hostsee.com Tidy RewritinguveFree Articles Directory | Hostsee.com If you are redesiging a site which previously had a bunch of URLs with a get string and you want to point them at a flat page or the site root you may find yourself with the problem that your rewrite appends the URL onto the rewrite.uveFree Articles Directory | Hostsee.com So, say for instance we had around 100 different instances of this page with different text in the getvar variable: oldpage.php?getvar=lets-remove-thisuveFree Articles Directory | Hostsee.com We would attempt to rewrite that to the site root with a rule like: rewriterule ^oldpage\.php$ / [R=301,L]uveFree Articles Directory | Hostsee.com Your attempts to rewrite oldpage.php?getvar=lets-remove-this to the homepage actually result in: /?getvar=lets-remove-thisuveFree Articles Directory | Hostsee.com Cleaning it upuveFree Articles Directory | Hostsee.com The solution to resolve this problem is incredibly easy, so much so, you need just one character. How is it done? Ironically, the question mark is the answer. You simply have to amend your original rule by adding a question mark after the substitution so / becomes /?uveFree Articles Directory | Hostsee.com rewriterule ^oldpage\.php$ /? [R=301,L]uveFree Articles Directory | Hostsee.com This will now rewrite oldpage to the site root and clear up the query string so you have a nice, clean rewrite. The question is the answer!uveFree Articles Directory | Hostsee.com
Marcus Miller is the owner of Bowler Hat Solutions and provides a range of affordable website design and internet marketing solutions for all shapes and sizes of businesses throughout the UK.uveFree Articles Directory | Hostsee.com Bowler Hat is currently promoting a new and powerful website product that combines consultation, strategy, website design, a content management system, search engine optimisation, search engine marketing and social media marketing for only £1000.00. Visit Bowler Hat Solutions for more information.uveFree Articles Directory | Hostsee.com
Article Source:
http://EzineArticles.com/?expert=Marcus_J_Miller
uveFree Articles Directory | Hostsee.com
Prev:Build and Own a Website - Build Value Into Your Site Next:Website Development Services - Benefits of Outsourcing
|