Reputation: 447
I'm trying to handle language and slug through my htaccess but I'm having some issues.
What I need is to turn this:
http://www.domain.com/es/product/lorem-ipsum
into this:
http://www.domain.com/product.php?lang=es&slug=lorem-ipsum
This is my .htaccess
RewriteEngineOn
RewriteBase /
RewriteRule ^(es|fr)/(.*)$ $2?lang=$1
RewriteRule ^product/(.*)$ product.php?slug=$1 [QSA,L]
But this is what I'm getting in product.php $_GET
Array
(
[lang] => 'es'
[slug] => 'lorem-ipsum/product/lorem-ipsum'
)
********** UPDATE ***********
If I change the first rule for this:
RewriteRule ^(es|fr)/(.*)$ $2?lang=$1 [R]
It works fine, but my URI changed for this:
http://www.domain.com/product/lorem-ipsum?lang=es
Upvotes: 0
Views: 363
Reputation: 18671
Try with:
RewriteEngine on
RewriteBase /
RewriteRule ^(es|fr)/(.*)$ /$2?lang=$1
RewriteRule ^product/(.*)$ /product.php?slug=$1 [QSA,L]
Upvotes: 1
Reputation: 432
Instead of matching all characters
(.*)
much just the letters like this
([a-zA-Z].*)
Upvotes: 0