For example, I have an address like: "www.example.com/popular.php?show=comments&id=1234" and I want to show it like "www.example.com/popular/comments/1234/". What should I do?
Depending on your technology you can use .htaccess
(apache) or httpd.conf
(iis).
In .htaccess
you would do something like this:
RewriteEngine On
RewriteRule ^popular/([^/]*)/([^/]*)$ /popular.php?show=$1&id=$2 [L]
What this does is is rewrite the requested url to the url with query variables. That is, if someone types in www.example.com/popular/comments/1234
then the server sees the url www.example.com/popular.php?show=comments&id=1234
The anatomy of the rewrite rule is this:
^popular
matches any resource that begins with "/popular" ([^/]*)
matches any thing between the 2 '/' characters, the first one is assigned to $1 and the second is assigned to $2.
Note, this does not redirect people who type in the old url to the new url. It only makes the new url function properly.