Last updated on December 27th, 2015 at 11:44 am
Here are couple of examples forÂ URLÂ usingÂ Â .htaccess
1)Rewriting user.php?id=12 to user-12.html
It is a simple redirection in which .php extension is hidden from the browserâ€™s address bar and dynamic url (containing â€œ?â€ character) is converted into a static URL.
RewriteRule ^user-([0-9]+)\.html$ user.php?id=$1
2) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz
Have you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1