This is not really specific to expression engine, but i’m trying to get mod rewrite to work, I’m starting from the official mod. I’m using the transcribe plugin, which is adding the language code to the url, but i’d like to have the country code too.
The current format of the urls is:
/en/us-news/article
I would like to change it to:
/us/en/news/article
Seems pretty simple, this regex should take care of it:
RewriteRule ^/index\.php/(ca|us)/(en|fr)/([^/]*)(.*)$ /index.php/$2/$1-$3$4 [L]But the urls aren’t rewritten properly.. This test url:
/us/en/news/article
Becomes:
/index.php/en/us-news/article/en/news/article
The variables contain:
$1: en
$2: us
$3: news
$4: /article/en/news/article
It’s $4 that’s the problem. It should only contain “/article” but a half-rewritten url is appended to the end of the variable. I have no clue where this comes from, could it be that apache parses the regex in several steps, making the replacements as it goes?
How could i make this work? What other process could be interfering?
The full .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [C]
RewriteRule ^/index\.php/(ca|us)/(en|fr)/([^/]*)(.*)$ /index.php/$2/$1-$3$4 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>Thanks,
Vincent