getting rid of the .php?=$varible in the URL ???

Discuss practical ways rearrange URLs using mod_rewrite.

getting rid of the .php?=$varible in the URL ???

Postby Guest » Mon Oct 11, 2004 3:09 pm

Hi my first post :)

Ok - so i have a sql db interacting with PHP. Basically i have a bunch of vitamin products listed in a DB..

There is a field called "type" wich represents the category of the vitamins (vitamin a, vitamin b, etc).

Im creating dynamic pages using variables in the urls:
http://www.myurl.com/display.php?c=Vitamin A and D
http://www.myurl.com/display.php?c=Vitamin B12

The problem is these urls are too long and not very SE freindly, i would like to change them to the shortest url possible and use / instead of .php?c=variable , maybe use display/1/ , display/2/ or something similar...

However the variable is used in display.php to call up the correct category.. so im not sure how to rewrite this...

-------------------------------------------------------
Part 2...

The urls to the individual products are using the product.php?=id=$id url.

I would like to change these to something also more SE friendly, such as product/$id

The current urls look like this:
http://www.myurl.com/product.php?id=17
http://www.myurl.com/product.php?id=18

Any help would be great !!
Guest
 

Postby phpmaven » Sat Nov 27, 2004 1:02 pm

RewriteRule ^display/(.*).php /product.php?id=$1

This would change:
http://www.myurl.com/display/17.php
to:
http://www.myurl.com/product.php?id=17
phpmaven
 
Posts: 5
Joined: Sat Nov 27, 2004 12:57 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 36 guests

cron