You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alexandru Duzsardi <al...@pitechnologies.ro> on 2016/03/25 09:13:06 UTC

[users@httpd] Rewrite domain to language specific page but no address bar redirection

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

 <http://www.pitechplus.com/> www.pitechplus.com

 

mobil: +4/ 0745-775.258

E-mail:  <ma...@pitechnologies.ro>
alexandru.duzsardi@pitechnologies.ro

Adresa: Str. Campul Painii 3-5 (Cladirea Coratim)

                Cluj-Napoca

                Romania

 


Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection

Posted by Christian Hettler <ch...@asknet.de>.
Hello Alexandru,

On Tue, Mar 29, 2016 at 01:23:54PM +0300, Alexandru Duzsardi wrote:
> I'm not sure what you mean
> For now I can't figure it out why does it behave like this ... if I try to access http://lang-fr.domain.com/ It says that /fr/index.php does not exist , I would like it to no try to find an index just access the path specified 
> 
> Regarding the PT flag , did you mean something like this ?

Yes. After a [PT]-Rule matches config processing will "start" again to process Alias, ScriptAlias and co.
Without [PT] no Alias processing happens and the result should/must be a file path.

> 
> # 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 [PT,L]
> 
> RewriteCond %{HTTP_HOST} ^lang-fr\.hostname\.com$ [NC] 
> RewriteRule ^(.*)$ - [PT,L]
> 
> # fr-lang 
> 

BTW: do you know mod_macro? It may improve the administion of your config for different lang.

Christian

> 
> Thank you!
> 
> 
> -----Original Message-----
> From: Christian Hettler [mailto:christian.hettler@asknet.de] 
> Sent: Tuesday, March 29, 2016 12:08 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection
> 
> did you check the flag [PT] for RewriteRule?
> 
> Christian
> 
> On Fri, Mar 25, 2016 at 04:27:46PM +0200, Alexandru Duzsardi wrote:
> > I tested a bit more , and unfortunately it breaks somewhere Probably I 
> > should have mentioned that the path’s after  ….hostname.com/  are not 
> > always physical paths on the disk , actually I think like 95% are not 
> > For example lang-fr.hostname.com/user/  , lang-fr.hostname.com/admin , 
> > lang-fr.hostname.com/admin/modules
> > or
> > hostname.com/fr/user , hostname.com/fr/admin , hostname.com/admin , 
> > hostname.com/admin/modules or lang-fr.hostname.com/fr/user , 
> > lang-fr.hostname.com/fr/admin , lang-fr.hostname.com/fr/admin/modules
> > 
> > And deeper paths are generated by drupal , and there is no index file 
> > , just the path
> > 
> > I tried to do this to remove the index.php file from the path , and 
> > this works but deeper paths don’t
> > 
> >   RewriteCond %{HTTP_HOST} ^lang-fr\.hostname\.com$ [NC]
> >   RewriteCond %{REQUEST_URI} !^/fr/.*$
> >   RewriteCond %{THE_REQUEST} ^GET.*index\.php$ [NC]
> >   RewriteRule ^(.*)index\.php/*(.*)$ /fr/$2 [L]
> > 
> > From: Marat Khalili [mailto:mkh@rqc.ru]
> > Sent: Friday, March 25, 2016 2:31 PM
> > To: users@httpd.apache.org
> > Subject: Re: [users@httpd] Rewrite domain to language specific page 
> > but no address bar redirection
> > 
> > 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!
> >  
> >  
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Rewrite domain to language specific page but no address bar redirection

Posted by Alexandru Duzsardi <al...@pitechnologies.ro>.
I'm not sure what you mean
For now I can't figure it out why does it behave like this ... if I try to access http://lang-fr.domain.com/ It says that /fr/index.php does not exist , I would like it to no try to find an index just access the path specified 

Regarding the PT flag , did you mean something like this ?

# 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 [PT,L]

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

# fr-lang 


Thank you!


-----Original Message-----
From: Christian Hettler [mailto:christian.hettler@asknet.de] 
Sent: Tuesday, March 29, 2016 12:08 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection

did you check the flag [PT] for RewriteRule?

Christian

On Fri, Mar 25, 2016 at 04:27:46PM +0200, Alexandru Duzsardi wrote:
> I tested a bit more , and unfortunately it breaks somewhere Probably I 
> should have mentioned that the path’s after  ….hostname.com/  are not 
> always physical paths on the disk , actually I think like 95% are not 
> For example lang-fr.hostname.com/user/  , lang-fr.hostname.com/admin , 
> lang-fr.hostname.com/admin/modules
> or
> hostname.com/fr/user , hostname.com/fr/admin , hostname.com/admin , 
> hostname.com/admin/modules or lang-fr.hostname.com/fr/user , 
> lang-fr.hostname.com/fr/admin , lang-fr.hostname.com/fr/admin/modules
> 
> And deeper paths are generated by drupal , and there is no index file 
> , just the path
> 
> I tried to do this to remove the index.php file from the path , and 
> this works but deeper paths don’t
> 
>   RewriteCond %{HTTP_HOST} ^lang-fr\.hostname\.com$ [NC]
>   RewriteCond %{REQUEST_URI} !^/fr/.*$
>   RewriteCond %{THE_REQUEST} ^GET.*index\.php$ [NC]
>   RewriteRule ^(.*)index\.php/*(.*)$ /fr/$2 [L]
> 
> From: Marat Khalili [mailto:mkh@rqc.ru]
> Sent: Friday, March 25, 2016 2:31 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Rewrite domain to language specific page 
> but no address bar redirection
> 
> 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!
>  
>  
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection

Posted by Christian Hettler <ch...@asknet.de>.
did you check the flag [PT] for RewriteRule?

Christian

On Fri, Mar 25, 2016 at 04:27:46PM +0200, Alexandru Duzsardi wrote:
> I tested a bit more , and unfortunately it breaks somewhere 
> Probably I should have mentioned that the path’s after  ….hostname.com/  are not always physical paths on the disk , actually I think like 95% are not 
> For example 
> lang-fr.hostname.com/user/  , lang-fr.hostname.com/admin , lang-fr.hostname.com/admin/modules 
> or
> hostname.com/fr/user , hostname.com/fr/admin , hostname.com/admin , hostname.com/admin/modules
> or
> lang-fr.hostname.com/fr/user , lang-fr.hostname.com/fr/admin , lang-fr.hostname.com/fr/admin/modules
> 
> And deeper paths are generated by drupal , and there is no index file , just the path
> 
> I tried to do this to remove the index.php file from the path , and this works but deeper paths don’t
> 
>   RewriteCond %{HTTP_HOST} ^lang-fr\.hostname\.com$ [NC]
>   RewriteCond %{REQUEST_URI} !^/fr/.*$
>   RewriteCond %{THE_REQUEST} ^GET.*index\.php$ [NC]
>   RewriteRule ^(.*)index\.php/*(.*)$ /fr/$2 [L]
> 
> From: Marat Khalili [mailto:mkh@rqc.ru] 
> Sent: Friday, March 25, 2016 2:31 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection
> 
> 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!
>  
>  
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Rewrite domain to language specific page but no address bar redirection

Posted by Alexandru Duzsardi <al...@pitechnologies.ro>.
I tested a bit more , and unfortunately it breaks somewhere 
Probably I should have mentioned that the path’s after  ….hostname.com/  are not always physical paths on the disk , actually I think like 95% are not 
For example 
lang-fr.hostname.com/user/  , lang-fr.hostname.com/admin , lang-fr.hostname.com/admin/modules 
or
hostname.com/fr/user , hostname.com/fr/admin , hostname.com/admin , hostname.com/admin/modules
or
lang-fr.hostname.com/fr/user , lang-fr.hostname.com/fr/admin , lang-fr.hostname.com/fr/admin/modules

And deeper paths are generated by drupal , and there is no index file , just the path

I tried to do this to remove the index.php file from the path , and this works but deeper paths don’t

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

From: Marat Khalili [mailto:mkh@rqc.ru] 
Sent: Friday, March 25, 2016 2:31 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection

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!
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Rewrite domain to language specific page but no address bar redirection

Posted by Alexandru Duzsardi <al...@pitechnologies.ro>.
Thank you so much , this looks like it’s working 

I just have to figure It out now how to remove the index.php from the uri path , since there isn’t any index.php , in /fr 

It’s just a drupal “virtualdir”

 

From: Marat Khalili [mailto:mkh@rqc.ru] 
Sent: Friday, March 25, 2016 2:31 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection

 

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!

 

 


Re: [users@httpd] Rewrite domain to language specific page but no address bar redirection

Posted by Marat Khalili <mk...@rqc.ru>.
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 
> <ma...@pitechnologies.ro>
>
> Adresa: Str. Campul Painii 3-5 (Cladirea Coratim)
>
>                 Cluj-Napoca
>
>                 Romania
>