Reputation: 145
I have the following URLs:
http://example.com/de/cat1/?q=product1
http://example.com/en/cat2/?q=product3
...
I would like to rename them as follows.
The first one should become: http://example.com/de/cat1/product1
. The second one should become: http://example.com/en/cat2/product3
In other words I just want to remove "?q=".
My .htaccess does not provide the correct result. It looks currently as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ ?q=$1 [NC,L]
If the users enters http://example.com/de/cat1/product1
it would turn it into: http://example.com/de/cat1/?q=/de/cat1/product1
.
How can I fix that?
Upvotes: 2
Views: 50
Reputation: 41219
This is because you are capturing the entire uri in a single group and using it as destination querystring. Replace your RewriteRule with the following :
RewriteRule ^(.+)/(.+)$ /$1?q=$2 [L]
Upvotes: 3