URL Query String is the string append to the web page URL. For example http://www.google.com/search?q=url+query+string, the string after the question mark (?) is the query string.
Most of the surfers will not care about the URL, which they consider them as alien language. However it would be nice if the URL can be translated into something more friendly to surfers, and most important to the search engine.
If your web server is Apache, you might follow the steps below to rewrite the URL (assume the folder of your website is webdir inside your document root):
- Enable the rewrite module in Apache. To do this, you need to edit the configuration file conf\httpd.conf.
- Find the following line and uncomment it.
LoadModule rewrite_module modules/mod_rewrite.so
- In some scenario, you need to set the AllowOverride parameter to All as well.
<Directory "document roots">
...
AllowOverride All
...
</Directory>
- Then restart the server.
- Create a file called .htaccess at webdir.
- Add the following coding or sample to .htaccess.
RewriteEngine On
RewriteBase /webdir/
RewriteRule index.html$ index.php [NC]
RewriteRule index/([^/]+)$ index.php?a=$1 [NC]
RewriteRule index/([^/]+)/([^/]+)$ index.php?a=$1&b=$2 [NC]
Now when you type:
- index.html, it will translate to index.php
- index/category, it will translate to index.php?a=category
- index/cateogory/linux, it will translate to index.php?a=category&b=linux
Advertisements
Leave a Reply