Forum Moderators: phranque

Message Too Old, No Replies

htaccess problem

htaccess

         

adityadid

11:46 am on Nov 13, 2008 (gmt 0)

10+ Year Member



I am new here, and even new to htaccess. I have a problem, plz help me out , i shall be thankfull if anybody could help me out.
I am working on a ecommerce site, which reqires that only the product name to be visible in url, without any id or any number
for instance
Url for category
www.domain.com/category_name/
Url for Products
www.domain.com/category_name/product_name/
Thanks in advance

adityadid

1:12 pm on Nov 13, 2008 (gmt 0)

10+ Year Member



Plz help me anybody asap.
:(

jdMorgan

1:44 pm on Nov 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This problem will require a scripted solution, because access to your database will be required in order to handle the "product name only" URLs.

You will need to do one of three things: Either modify the shopping cart, add a "wrapper" script around it and modify your .htaccess file or server config file to call the wrapper instead of calling the cart directly, or use a RewriteMap (see Apache mod_rewrite) to call a mapping script (e.g. written in PERL) to access the cart database, look up the product id, and then call the cart with that id. This last solution requires access to the server config files, and will not be available on shared hosting.

None of these solutions are simple, and none are easy enough to handle in a discussion forum context. I suggest that you hire a local consultant to make these changes if you do not feel comfortable enough to do them yourself.

It is also possible that you may be able to buy a "plug-in" for the cart which will do what you want. I suggest researching this at the cart-makers site, and also on any forums dedicated to your specific cart.

Jim

adityadid

4:53 am on Nov 14, 2008 (gmt 0)

10+ Year Member



Thanks for replying Jim. U made a gr8 effort, i am really thankfull to u.

I think i need to more descriptive. Its a simple php site with listing of products and product details page.
1. The first page is the product listing page based on a category say product_list.php
the url to this page is www.domain.com/product_list.php?cat=2 (suppose cat is the category id, and name of category is audio)
I want the url to be www.domain.com/audio/

2. The 2nd page is product details page of a specific product say product_details.php
the url to this page is www.domain.com/product_details.php?prd=celina ( suppose prd is product name, which falls in category audio)

The url to this page should be www.domain.com/audio/celina/

I think this makes sence.

Thanks

jdMorgan

5:00 am on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In order to associate the word "audio" with the category "2", you will need a scripted solution, as stated above. In order to make a non-textual URL translation, some code somewhere must access your database, because this is not simply a matter of "re-arranging the existing characters" in the URL.

Jim

adityadid

5:11 am on Nov 14, 2008 (gmt 0)

10+ Year Member



Thanks again Jim.
I know php but not htaccess :( . I can send category name in url say product_list.php?cat=audio but the url i want to show in address bar is www.domain.com/audio/

Similarly for produt details the page i can send for is product_details.php?cat=audio&prd=celina
and the url should be www.domain.com/audio/celina/

adityadid

5:48 am on Nov 14, 2008 (gmt 0)

10+ Year Member



Hi, Jim here is An Update
Trying myself to make the htaccess file as follows, its for product details page

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^(.*)/(.*)/$ product_details.php?prd=$2&cat=$1

Thanks
Adi

g1smd

1:58 pm on Nov 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As jim said above, this is not a problem that .htaccess can easily solve on it's own.

You will need a PHP script that checks the requested URL, and accesses your database to get the data required.