httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marat Khalili <...@rqc.ru>
Subject Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection
Date Fri, 25 Mar 2016 12:30:48 GMT
It's tricky. Here's a rule set that works for me (but it may depend on 
Apache version and configuration):

# fr-lang {
   RewriteCond %{ENV:REDIRECT_STATUS} ^$
   RewriteCond %{REQUEST_URI} ^/fr$
   RewriteRule ^fr$ http://lang-fr.hostname.com/ [L,R=302]

   RewriteCond %{ENV:REDIRECT_STATUS} ^$
   RewriteCond %{REQUEST_URI} ^/fr/.*$
   RewriteRule ^fr/(.*)$ http://lang-fr.hostname.com/$1 [L,R=302]

   RewriteCond %{HTTP_HOST} ^www\.lang-fr\.hostname\.com$ [NC]
   RewriteRule ^(.*)$ http://lang-fr.hostname.com/$1 [R=301,L]

   RewriteCond %{HTTP_HOST} ^lang-fr\.hostname\.com$ [NC]
   RewriteCond %{REQUEST_URI} !^/fr/.*$
   RewriteRule ^(.*)$ /fr/$1 [L]

   RewriteCond %{HTTP_HOST} ^lang-fr\.hostname\.com$ [NC]
   RewriteRule ^(.*)$ - [L]
# fr-lang }

Repeat for each language (probably it's possible to make a single rule 
set for all languages, but I didn't try it).

--

With Best Regards,
Marat Khalili


On 25/03/16 11:13, Alexandru Duzsardi wrote:
>
> Hello,
>
> I’ve search around on search engines but I could not find any answers 
> that solve my dilemma
>
> I have a VirtualHost configured to respond on multiple hostnames
>
> Example: hostname.com , lang-fr.hostname.com , lang-nl.hostname.com , 
> fr-lang.hostname.com , nl-lang.hostname.com
>
> Now , what I would like is that
>
> If somebody is accessing lang-fr.hostname.com and fr-lang.hostname.com 
> to actually  see the pages under hostname.com/fr/… but without 
> redirection
>
> Like lang-fr.hostname.com/users to actually be hostname.com/fr/users , 
> and so on for other languages.
>
> I’ve tried some things but always get to many redirects or some other 
> error and can’t figure it out why is that happening , but if I had to 
> guess is because I’m using RewriteCond  correctly.
>
> Thank you in advance!
>
> ----
>
> Cu stima,
>
> Kind regards,
>
> *Alexandru Duzsardi*
>
> System Administrator
>
> *PITECH+PLUS*
>
> www.pitechplus.com <http://www.pitechplus.com/>
>
> mobil: +4/ 0745-775.258
>
> E-mail: alexandru.duzsardi@pitechnologies.ro 
> <mailto:alexandru.duzsardi@pitechnologies.ro>
>
> Adresa: Str. Campul Painii 3-5 (Cladirea Coratim)
>
>                 Cluj-Napoca
>
>                 Romania
>


Mime
View raw message