Support forum login

©2006-2008 IAAI Software

Contact Us

URL Rewrite Help

Submitted by frychiko on Fri, 2007-11-09 16:05.

Hi David,

I would like to test URL Rewrite. I have Price Tapestry installed on my computer at:

localhost/peter/price (opt/lampp/htdocs/peter/price)

Where do I put the .htaccess file? (For now I put it in the /price directory)

Right now I'm getting this as an example when clicking on a product (Syncmaster 226BW) in product search:

http://localhost/syncmaster-226bw/

instead of what I want:

http://localhost/peter/price/product/syncmaster-226bw/

I tried changing "RewriteBase" to "/peter/price" but nothing updates on the URL when I refresh the browser so I'm thinking the .htaccess file is not even being looked at.

regards,
Peter

Submitted by dmorison on Fri, 2007-11-09 16:10.

Hi Peter,

That is correct - .htaccess goes in the /price directory (the same directory as Price Tapestry is installed in).

RewriteBase in this instance should be:

/peter/price/

..but also importantly you must have $config_baseHREF set as follows in config.php

  $config_baseHREF = "/peter/price/";

..and also (of course):

  $config_useRewrite = True;

This should result in product URLs similar to (not quite as in your post):

http://localhost/peter/price/product/syncmaster-226bw.html

Hope this helps,
Cheers,
David.

Submitted by frychiko on Sat, 2007-11-10 02:00.

Hmm.. that is exactly as I have it know...

Oh! Now I realise the problem (I think). I have modified pricetapestry so products are pulled from a master product table rather than accessing the products table directly. The URL I have is:

products.php?id=5

This is the id of product syncmaster-226bw.

I'm guessing the .htaccess is not picking up on this because the URL is different than the rule you've originally written, but I don't know how to convert this URL to:

/price/product/syncmaster-226bw.html

I have the name of the product stored in a variable, so I can put that in the url link for the product in the search results. (name = "syncmaster-226bw".

What would be the new rule?

regards,
Peter

Submitted by frychiko on Sat, 2007-11-10 02:27.

Sorry David, PLEASE IGNORE MY PREVIOUS REPLY (For now at least).

cheers,
Peter

Submitted by frychiko on Sat, 2007-11-10 09:10.

Ok, I managed to get URL rewriting working with my modified setup. Now there's an image problem, no images show up:

For example, in "product.html" I place somewhere:

<img src="images/4.gif" />

This results in no image (of course with full path, image shows), and the source is:

http://localhost/peter/price/product/samsung-226bw/images/4.gif

I guess I need a rewrite rule for images so it's not appended onto current URL... What would this rule be? I've tried various examples from the web, but nothing is working so far.

regards,
Peter

Submitted by dmorison on Sat, 2007-11-10 09:27.

Hi Peter,

You don't need a full path for the images, all you need to make is make sure that you use absolute rather than relative URLs.

What you have at the moment is a relative URL, so the browser looks for images/4.gif in the current directory, which if you are using re-write makes the browser think is somewhere deep in your site. To fix it, all you need to is add a leading / to the image src, and that makes the browser look for the image relative to the top level directory of your site, for example:

<img src="/images/4.gif" />

That should sort it!
Cheers,
David.

Submitted by frychiko on Sat, 2007-11-10 09:35.

Ok I see.

What if the site is not in the document root? Mine is in /peter/price/
So I guess the following would be the best solution?

$src = $config_baseHREF."images/4.gif";

<img src="<?=$src?>">

cheers,
Peter

Submitted by dmorison on Sun, 2007-11-11 15:41.

Hi Peter,

Yes - using $config_baseHREF is a good way to do it. Instead of the above you could use (whilst in HTML mode):

<img src="<?=$config_baseHREF?>images/4.gif">

Cheers,
David.

Submitted by nosferatu on Thu, 2008-10-09 13:55.

please please tell me how have you made the path to de product like this http://localhost/syncmaster-226bw/

My product path is http://localhost/product/syncmaster-226bw/

Submitted by dmorison on Thu, 2008-10-09 13:58.

Hi,

The details are in this thread:

http://www.pricetapestry.com/node/2003

...make sure to read it all first as there are some complications that you need to be aware of doing this...

Cheers,
David.

--
Developer, Price Tapestry
For unrelated PHP, MySQL or Affiliate Marketing tech help please post your questions on my personal forum

Submitted by nosferatu on Thu, 2008-10-09 14:04.

Thank you very much