You are here:  » htaccess replace ^category by other term

Support Forum



htaccess replace ^category by other term

Submitted by pat on Wed, 2009-12-16 20:50 in

Hello David

What should i modify in order to have other terms than category or product in my urls?

Now I have this:

http://www.mysite.com/category/Pendentifs/

and I'd like

http://www.mysite.com/bijoux/Pendentifs/

same with

http://www.mysite.com/product/pendentif.html

I'd like to have
http://www.mysite.com/stone/pendentif.html

Thanks

Pat

Submitted by support on Thu, 2009-12-17 09:01

Hi Pat,

You basically just need to change the rules in .htaccess to use your new terms, and then anywhere throughout the site that generates those paths needs to be changed to the new term. For the product example; look for the following code in .htaccess

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

...and REPLACE with:

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

...and then within each of the following files, perform a Search and Replace with your text editor, searching for "product/" and replace with "stone/":

index.php
products.php
reviews.php
search.php
sitemap.php

For the category substitution; look for the following code in .htaccess:

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]

...and REPLACE with:

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

...and then search and replace in the same files as above, searching for "category/" and replacing with "bijoux/".

Hope this helps!

Cheers,
David.