I have a bit of a dilemma with mod_rewrite.
How do I write a rule that will decide the following:
If i browse /en/page/page I want to rewrite this to:
index.php?language=en&page=/page
BUT if i browse just /page I want to rewrite this to:
index.php?page=/page
Is this possible?
Edit:
/page is just a random dynamic pagename, it could aswell be whatever.
I need a rule that checks like /se == a string, and not longer than 2 characters>/page --> index.php?lang=se&page=/page and if browsing page /page it will notice that /page == longer than 2 characters and rewrite to index.php?page=/page
Edit2: Found the anser to my question:
RewriteEngine On RewriteBase / ## Check if its not a filename or dirname RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ## Rewrite rules RewriteRule ^(.{2})/(.*)$ index.php?lang=$1&page=$2 [L] RewriteRule ^(.*)$ index.php?page=$1 [L,QSA]