I'm looking for a regulair expression for a .htaccess
file inside my PHP server.
What I want is that it detects the language from the first directory as parameter:
- nl
- en
- be
- de
Any other options must be treated as a directory or filename. The language must be given as parameter without corrupting any other parameters.
Also I want the last /
replaced by .php
.
Some examples:
host.com/nl/index/ -> host.com/index.php?lang=nl
host.com/de/test/abc/ -> host.com/test/abc.php?lang=de
host.com/be/a/b/c/?t=23 -> host.com/a/b/c.php?lang=be&t=23
Is this possible? I can't get it to work, I hope someone will help me out!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule >>> requested expression and replacing pattern <<<
</IfModule>