.htaccess tutorial

htaccess Elite


rewrite virtual folder into subdomain

Ask your mod_rewrite and Redirection questions here, and get answers!

rewrite virtual folder into subdomain

Postby doonee » 14 Apr 2008 18:48

hello all

first off, im a total looser with mod_rewrite
due to a client request, im looking at the following setup:

a joomla installation using 2 third party addons, one to add multilanguage capabilties (say for english, french and spanish)
and another to rewrite the joomla standart urls to pURLs. so far so good.

now, the setup produces nicely working sef URLS organizing the languages as virtual folders, as in:
domain.com/french etc.

the client, however, insists in having the languages distributed over subdomains instead of folders, as in:
spanish.domain.com etc.

none of the code which rewrites the standrt urls into pURLs is within the htaccess file.



the task, thus, seems to present itself as such:
rewrite the language folders pURLs -which themselves, mind you, are already rewritten from the standart CMS URLs, into
subdomain pURLs, while keeping the whole thing working .....

id be grateful if somone could confirm whether this is this actually possible (i have some doubts about this)
and what a step by step approach may look like.

technically, google and users with their browsers must see french.domain.com.
hence, i assume, the requests resulting from people clicking on links need first be internally adressed to domain.com/french, and then the served page need to be again rewritten to french.domain.com.

in addition, people attempting to access domain.com/french directly need to be redirected to french.domain.com permanently, which -me thinks- is where the cat may be biting its own tail.

hope someone can shed seme light on this mess...
thanks in advance for all efforts

best regards :)
dee
doonee
 
Posts: 7
Joined: 14 Apr 2008 17:28

Re: rewrite virtual folder into subdomain

Postby doonee » 28 Apr 2008 17:41

hi again

id be pretty happy already if someone could point out to me whether the above idea is technically conceivable, somehow,
or just nonsense ... :)

best
dee
doonee
 
Posts: 7
Joined: 14 Apr 2008 17:28

Re: rewrite virtual folder into subdomain

Postby mod_rewrite » 09 May 2008 22:57

Yes its definately possible, kinda cool actually!

First off, can you modify the joomla or whatever is outputting html so that the links are all printed as spanish.domain.com instead of domain.com/spanish/? If so then the solution is easy.
mod_rewrite
 
Posts: 102
Joined: 30 Oct 2006 19:55

Re: rewrite virtual folder into subdomain

Postby doonee » 10 May 2008 04:57

hi
thanx for the reply... :)

theoretically yes, at the expense of hacking the extension that does the rewiriting, which
a) isn't too easy, according to the developper, and
b) undesireable, as each important update of the extension had to be hacked again & again...

the attractivity idea of 're-rewriting' the extensions output instead of touching the extension is what started all of this. :)
the point of departure is thus domain.com/spanish, unfortunately.
is that kind of re-rewriting, or whatever one may call it, possible ?

regards
dee
doonee
 
Posts: 7
Joined: 14 Apr 2008 17:28

Re: rewrite virtual folder into subdomain

Postby mod_rewrite » 11 May 2008 04:04

Heres what I'm saying.. Of course it is possible using mod_rewrite or mod_alias to redirect all client requests for domain.com/spanish to spanish.domain.com That is pretty easy. The part that you need to think about is linking to spanish.domain.com instead of domain.com/spanish

IOW, will your html output (even on spanish.domain.com) still link to domain.com/spanish? Thats not good. It will still work because when they click on domain.com/spanish they will be redirected to spanish.domain.com but that means ALL requests for ALL non-english urls will be 301 redirected, which is just crazy and will fill up your logs like crazy.

Take this forum, a url for viewforum.php?forum=12 is the real url, but we have hacked phpBB so that the output throughout the site is mod-rewrite-vf12.html

Thats what I am saying, so hacking joomla is neccessary if you really want to do it right.
mod_rewrite
 
Posts: 102
Joined: 30 Oct 2006 19:55

Re: rewrite virtual folder into subdomain

Postby doonee » 13 May 2008 01:19

Will your html output (even on spanish.domain.com) still link to domain.com/spanish? Thats not good.

yup, i had played around with the redirection part, and the pages that are being served link to domain.com/spanish

when they click on domain.com/spanish they will be redirected to spanish.domain.com but that means ALL requests for ALL non-english urls will be 301 redirected, which is just crazy


hm, im getting it...
that wouldnt be too SEO either, would it ?

hacking joomla is neccessary if you really want to do it right.

ok.
hacking the add-on in this case,
which gets me back to square 1...

just so i could test around some, what would the code look like ?

rgds
dee
doonee
 
Posts: 7
Joined: 14 Apr 2008 17:28

Re: rewrite virtual folder into subdomain

Postby mod_rewrite » 15 May 2008 05:05

The code to do what exactly?
mod_rewrite
 
Posts: 102
Joined: 30 Oct 2006 19:55

Re: rewrite virtual folder into subdomain

Postby doonee » 30 May 2008 23:10

sorry for the delay, i overlooked the reply

The code to do what exactly?



i was referring to this bit here...

Code: Select all
it will still work because when they click on domain.com/spanish they will be redirected to spanish.domain.com but that means ALL requests for ALL non-english urls will be 301 redirected


rgds
dee
doonee
 
Posts: 7
Joined: 14 Apr 2008 17:28

Re: rewrite virtual folder into subdomain

Postby archana » 18 Aug 2008 11:51

Can you give me your code which will use same file for two different languages?

Like,

http://www.example.com/en/user.php

http://www.example.com/fr/user.php


I have user.php in root folder.

I want as http://www.example.com/user.php?lang=en or http://www.example.com/user.php?lang=fr
archana
 
Posts: 1
Joined: 18 Aug 2008 11:40


Return to Redirect or Rewrite Questions