You are here:  » Simpler Rewriting

Support Forum



Simpler Rewriting

Submitted by coyote on Mon, 2008-01-21 21:01 in

Hello David

I want to have these kinds of urls instead of default ones :

mysite.com/shop/name-of-product.html

instead of

mysite.com/shop/product/name-of-product.html

and

mysite.com/shop/name-of-category

instead of

mysite.com/shop/category/name-of-category

and so on

i tried some modifications in the htaccess but i encountered problems :

first the links in the page lead to 404 (example : the links to products in a category page)
second the become category:name-of-category: instead of name-of-category

how to make it work ?

Thanks in advance for your help !

Cheers
Coyote

Submitted by support on Tue, 2008-01-22 09:16

Hello Coyote,

The basic rule, which would need to go at the very end of your .htaccess would be:

RewriteRule ^(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

You can get away with this as none of non-rewrite pages generated by Price Tapestry end in .html.

However, this isn't all you need to do, as there are many places in the code that generate the product link using /product/ as part of the URL. You will be able to identify these by searching for:

if ($config_useRewrite)

...and

if ($rewrite)

In the code following these statements, look for the "product/" string, which you can then change to just "/". Furthermore, changes will then need to be made on the product page itself to ensure that all follow on links use the correct URL, as they expect to be relative to /product/ which if you remove this rule they would not be...!

Cheers,
David.

Submitted by coyote on Tue, 2008-01-22 10:27

Hello David

Thank your for your answer

Actually i have no problem with product page rewriting

the probleme comes with category rewriting :

this is default rewriting :

RewriteRule ^category/$ categories.php
RewriteRule ^category/(.*)/$ search.php?q=category:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^category/(.*)/(.*).html$ search.php?q=category:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]

I tried this :

RewriteRule ^categories.php$ categories.php
RewriteRule ^(.*).php$ search.php?q=category:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^(.*)-(.*).php$ search.php?q=category:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]

But it seems it doesn't work (i did changes in the corresponding files), did i forgot something ?

Thank you for you help

Cheers,
Coyote

Submitted by support on Tue, 2008-01-22 13:05

Hi,

Are your new rules just being ignored (404) or do they try and re-write but do not pass the correct variables through to search.php?

Cheers,
David.

Submitted by coyote on Tue, 2008-01-22 14:12

Hi

They do not pass the correct variables through to search.php

Cheers,
Coyote

Submitted by support on Tue, 2008-01-22 14:42

Hi,

Can you email me a link to your site so I can see what's going on, it might be easier to help that way (reply to your reg code or forum registration email is the easiest way to get me...)

Cheers,
David.