Facebook Twitter Reset

This Tutorial Has Been Viewed 3,913 Times.

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

VN:F [1.9.13_1145]
Rating: 5.5/10 (2 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 2 votes)
Url rewriting examples using .htaccess, 5.5 out of 10 based on 2 ratings

Incoming search terms:




You will also be interested in ,

4 Responses to “Url rewriting examples using .htaccess”

  1. Maxoderm
    April 8, 2009 at 2:01 am #

    how’re you doing guys?

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: -1 (from 1 vote)
  2. InjetteNeda
    April 29, 2009 at 5:42 pm #

    Amazing !!!!

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: -1 (from 1 vote)
  3. Drixinipuff
    May 10, 2009 at 11:22 am #

    Hello all
    I am new to this board but this is superbbbbbbbbbbbbb

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: -1 (from 1 vote)
  4. Drixinipuff
    May 23, 2009 at 8:44 pm #

    Hello all
    I am new to this board, a good one.

    VA:F [1.9.13_1145]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.13_1145]
    Rating: -1 (from 1 vote)

Leave a Comment

Spam protection by WP Captcha-Free

Affordable Seo PackagesSeo BlogEdu Backlinks
More in Html (7 of 19 articles)