Url rewriting examples using .htaccess
Hi here i will explain some URL rewriting magic using .htaccess file.
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.
RewriteEngine on
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.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
Related posts:








how’re you doing guys?
Amazing !!!!
Hello all
I am new to this board but this is superbbbbbbbbbbbbb
Hello all
I am new to this board, a good one.