Current location: Hot Scripts Forums » Other Discussions » Web Servers » create clean URL with .htaccess (Rewrite Engine)


create clean URL with .htaccess (Rewrite Engine)

Reply
  #1 (permalink)  
Old 03-09-07, 04:40 AM
studenteye's Avatar
studenteye studenteye is offline
Newbie Coder
 
Join Date: Jul 2004
Location: UK
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
create clean URL with .htaccess (Rewrite Engine)

The original URL is

http://www.mysite.com/index.php?acti...&product_id=34


i want convert this bad url into clean & short url like this


http://www.mysite.com/products/productname


i think its possible with url rewrite engine. but i donot know how use write mod
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-09-07, 05:07 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Topic moved to web servers.

And try this.
Code:
RewriteEngine On
RewriteRule ^products\/(.+)$ index.php?action=products&product_id=$1
You will have to change your PHP script so that it finds the product by name. If you don't want to do that, you can pass the ID in the URL along with the name. Like this for example:

Code:
RewriteEngine On
RewriteRule ^products\/(.+)-([\d]+)$ index.php?action=products&product_id=$2
So your URLs would look like: http://example.com/products/productname-42
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Read url and create links tefc2006 PHP 1 12-03-06 03:02 PM
Wanting to create a search engine dude1898 Visual Basic 0 11-20-06 01:14 PM
how to create search engine using c? afdhal C/C++ 0 03-07-06 10:04 PM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 01:42 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.