N0lf N0lf - 1 year ago 79
Apache Configuration Question

How to rewrite specific URL using htaccess

I've been breaking my head on this for quite some time and I don't see the solution.

I want to rewrite an URL with a GET language parameter to a more clean URL.

For instance :

Needs to be =

this works fine with this rewrite rule :

RewriteRule ^(en|nl|fr|de)/?$ /?lang=$1 [L]

But I can't get it to work on URLs like these :



That need to be :



Anyone has an idea what I'm missing in my rewrite rule to make this work ?

Thanks in advance !

Answer Source

You will need an additional rewrite rule for handling /en/about.php:

RewriteEngine On

RewriteRule ^(en|nl|fr|de)/([\w-]+\.php)$ $2?lang=$1 [L,QSA]

RewriteRule ^(en|nl|fr|de)/?$ /?lang=$1 [L,QSA]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download