BToTheAToTheBABA
asked on
htaccess RewriteRule using domain name for language as a parameter.
hi,
Im managing a bilingual website.
Two languages can be used with URL like this.
www.website.com/product/computer.html?lang=en
www.website.com/product/computer.html?lang=jp
Also
www.website.com/product/apple/laptop.html?lang=en
www.website.com/product/apple/laptop.html?lang=jp
No other pages/url_patterns in the website needs Language settings.
I need a redirect rule to use with this 2 patterns with language in domain part of URL.
en.website.com/product/com puter.html
should be processed internally as
www.website.com/product/computer.html?lang=en
and
jp.website.com/product/app le/laptop. html
should be processed as
www.website.com/product/apple/laptop.html?lang=jp
As you can see
domain part en/jp should become ?lang=en/jp
and should be valid with this URL patterns
xxxx/product/xxxxxx
AND
xxxx/product/apple/xxxxx
RewriteRule can be in httpd.conf OR htaccess.
Since Im not good at this RewriteRule I request you to have this as simple as possible.
Thank you for all in advance.
Im managing a bilingual website.
Two languages can be used with URL like this.
www.website.com/product/computer.html?lang=en
www.website.com/product/computer.html?lang=jp
Also
www.website.com/product/apple/laptop.html?lang=en
www.website.com/product/apple/laptop.html?lang=jp
No other pages/url_patterns in the website needs Language settings.
I need a redirect rule to use with this 2 patterns with language in domain part of URL.
en.website.com/product/com
should be processed internally as
www.website.com/product/computer.html?lang=en
and
jp.website.com/product/app
should be processed as
www.website.com/product/apple/laptop.html?lang=jp
As you can see
domain part en/jp should become ?lang=en/jp
and should be valid with this URL patterns
xxxx/product/xxxxxx
AND
xxxx/product/apple/xxxxx
RewriteRule can be in httpd.conf OR htaccess.
Since Im not good at this RewriteRule I request you to have this as simple as possible.
Thank you for all in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can you explain these lines ?
RewriteCond %{QUERY_STRING} !lang=[ej][np] [NC]
RewriteCond %{REQUEST_URI} ^/product/ [NC]
RewriteCond %{HTTP_HOST} ^(en|jp)\. [NC]
RewriteRule .* %{REQUEST_URI}?lang=%1 [L,QSA]