Forum Moderators: phranque
I want to follow the [domain.com...] and [domain.com...] format, with the language code (only fr or en) first.
However I would like to provide the option of [domain.com...] format that would automatically redirect the page to the default language (english in this case).
I'm working with the following code but its really confusing me and I want to know how I can fix it. If anyone can help me or give me links ill be very grateful.
CODE:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}!^(en¦fr)(.+)$ [NC]
RewriteRule ^.*$ /en/$1 [R]
thanks in advance,
shaun
If you only want to make sure that the url without the language code gets redirected to the English one, then you only need this:
RewriteEngine On
RewriteBase /
RewriteRule ^news/([0-9]+)/?$ /en/$1 [R,L]
But if this code is supposed to do URL to filename mapping (so your script will be called each time someone requests such a page, then the following will do the job:
RewriteEngine On
RewriteBase /
RewriteRule ^news/([0-9]+)/?$ en/news/$1 [NC]
RewriteRule ^(en¦fr)/news/([0-9]+)/?$ your_script?language=$1&newsid=$2 [NC,L]