Tutorials >> View >> 5
Yahoo chat: marklester_aover
Bookmark and Share

Search Engine Friendly URL - create a virtual directory or convert url query string to a directory using .htaccess

Using mod_rewrite or .htaccess will help your site URL a much more Search Engine Friendly URL by converting the URL query string to a directory like this http://mysite.com/index.php?page=gallery&task=view to http://mysite.com/gallery/view/. Simply name the directory by the name of the value of your GET variable on your url. Also you can get the value of the URL by calling the name of the variable on the url that you have represent. So place the code inside your .htaccess file.

Learn the codes below:

# put this .htaccess file to your site root directory #

Options +FollowSymLinks
# start the Rewrite Engine or Rewrite Mode #
RewriteEngine On

# convert the directory type url to url query #
# "$1" is a variable to set the value of "folder" #
RewriteRule ^([a-zA-Z0-9_\s-]+)(/)?$ index.php?folder=$1

Click image to download the Zip file: SEF-URL-virtual-dir.zip

# of Comments (1)

by: Mark Abucayon

Very helpful information I will use this one later when Im not that busy hehehe, thanks for sharing your Ideas. Great Job. Thank you.

2008-06-05

Add your comment here...

Please feel free to make a comment and suggestion on this tutorial. Your comment and suggestion will help improve the tutorial for the benefit of you and others. Thank you...

Name : *
Email Add : *
URL (include http://):
Messages : *
Security Code : *
(*) Must not leave blank.
captcha

Our Main Services

We develop and deliver the following services:

Latest News...

Search My Site

 This Site   Web

Google Ads

Google Ads

Powered By:

Advertise

Place your Custom Advertise here $29 for 1 month. Image dimension 276x180 pixels. Click the Paypal "Buy Now" button below.