mod_rewrite – Part 3: build your own “fantasy” URL

mod_rewrite tutorial: In this tutorial, I will show you how to make “bestethnic.html” to instead “product.php?id=3”. Before you read, make sure you have understood part 1 and part 2 from this series.

Assume, you work on www/product (it root folder for

Ok, folow this steps:

1. Create .htaccess on your folder.
2. Write this code:

1 RewriteEngine On
3 # translate bestethnic.html to product.php?id=3
4 RewriteRule ^bestethnic\.html$ product.php?id=3

3. create product.php
4. write this code at product.php

1 <?php
2 echo "you have choose product id: #".$_GET['id'];
3 >

Catch idea?

As phpeveryday.php

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s