Url rewriting examples using .htaccess

This Tutorial Has Been Viewed 3,936 Times.

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 ,

Tags: , , ,

4 Responses

  1. Maxoderm says:

    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 says:

    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 says:

    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 says:

    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 Reply

Spam protection by WP Captcha-Free

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks
More in Apache, PHP (108 of 138 articles)