Problem with virtual lang library

New to mod_rewrite? This is a good place to start.

Problem with virtual lang library

Postby Maxeenie » Tue Sep 15, 2009 2:52 am

Hi there,

I've concerted the language cookie into a virtual library so that google indexes different language pages as well. The problem is that I'd like the original URLs to work as well.

The new rule for converting domain.com/lang/xx-product.html is

Code: Select all
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?iso_lang=$1&id_product=$2$4 [L,E]


and the original rule rewriting domain.com/xx-product.html is

Code: Select all
RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$1$3 [L,E]


I had to comment out the old code, cos it also interferes with the new one as the string xx-product is there in both URLs. How can I change the old rule so that it won't interfere with the new one?

I need this cos I want the old links to remain functional as well.

Thanks for helping
Maxeenie
 
Posts: 3
Joined: Tue Sep 15, 2009 2:41 am

Postby richardk » Tue Sep 15, 2009 5:53 pm

They should work together, do you have more mod_rewrite?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Maxeenie » Tue Sep 15, 2009 11:17 pm

Yes, here's the full list. The old ones are now commented out.

Code: Select all
# URL rewriting rules
#RewriteRule ^([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$2$4 [L,E]
#RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?id_product=$1$3 [L,E]
#RewriteRule ^([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ category.php?id_category=$1 [QSA,L,E]
#RewriteRule ^content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ cms.php?id_cms=$1 [QSA,L,E]
#RewriteRule ^([0-9]+)__([a-zA-Z0-9-]*)(.*)$ supplier.php?id_supplier=$1$3 [QSA,L,E]
#RewriteRule ^([0-9]+)_([a-zA-Z0-9-]*)(.*)$ manufacturer.php?id_manufacturer=$1$3 [QSA,L,E]

# URL rewriting rules
## Now with ...iso_lang/category/product.html
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/([a-zA-Z0-9-]*)/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?iso_lang=$1&id_product=$3$5 [L,E]
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/([0-9]+)\-([a-zA-Z0-9-]*)\.html(.*)$ product.php?iso_lang=$1&id_product=$2$4 [L,E]
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ category.php?iso_lang=$1&id_category=$2 [QSA,L,E]
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/content/([0-9]+)\-([a-zA-Z0-9-]*)(.*)$ cms.php?iso_lang=$1&id_cms=$2 [QSA,L,E]
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/([0-9]+)__([a-zA-Z0-9-]*)(.*)$ supplier.php?iso_lang=$1&id_supplier=$2$4 [QSA,L,E]
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/([0-9]+)_([a-zA-Z0-9-]*)(.*)$ manufacturer.php?iso_lang=$1&id_manufacturer=$2$4 [QSA,L,E]
RewriteRule ^([a-ik-zA-Z][a-zA-Z])/(.*)$ $2?iso_lang=$1 [L,E]
Maxeenie
 
Posts: 3
Joined: Tue Sep 15, 2009 2:41 am

Postby Maxeenie » Tue Sep 15, 2009 11:27 pm

I think I found the problem, it's old rule #1 that interferes with new rule #2.
I've tried uncommenting old rule only old rukle #2-3, and it works now as I wanted.

Thanks for the tip!
Maxeenie
 
Posts: 3
Joined: Tue Sep 15, 2009 2:41 am

Postby richardk » Wed Sep 16, 2009 2:37 pm

You could probably put old rule #1 after new rule #2 and all your old URLs would most likely work.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

cron