dir1-dir2-dir3-file-language.html
to
index.php?l=dir1:dir2:dir3&target=file&lang=language
It works with the following rules:
- Code: Select all
RewriteRule ^([a-z0-9\-]+)-([a-z0-9]+)-([a-z0-9]+)\.html?$ temp/l=$1&a=$2&lang=$3
RewriteRule ^temp/(.*)-(.*)$ temp/$1:$2
RewriteRule ^temp/l=([a-z0-9:]+)&a=([a-z0-9]+)&lang=([a-z0-9]+)$ index.php\?l=$1&a=$2&lang=$3.html
First rule makes sure the parameters l, a and lang are set
the second rule replaces all - with :
the third rule links this url to index.php
I am new to mod_rewrite, and I've got a gut feeling I am doing it wrong It bugs me that I have to rewrite the URL to temp/... I'd rather do something like this:
- Code: Select all
RewriteRule ^([a-z0-9\-]+)-([a-z0-9]+)-([a-z0-9]+)\.html?$ index.php?l=$1&a=$2&lang=$3
RewriteRule ^index\.php\?(.*)-(.*)$ index\.php\?$1:$2
But then, the Rewriting stops after the first rule. It forms the url index.php?l=dir1-dir2-dir3&a=file&lang=language. The '-' isn't replaced with ':' no more.
Am I missing something here?