Multiple subdomains (replicate code or not?)

Discussion in 'Apache' started by JRJR, Dec 5, 2006.

  1. #1
    Hi,

    I'm developing a new website and I want to create multiple subdomains where the only difference will be the language. My doubt is: do I need to replicate all the files from the root directory to each of the subdomain directory or can I do the "conversion" using the mod_rewrite in .htaccess?

    I'm trying to use a rewrite rule to redirect the a file in the main directory, having the following in the .htaccess of the subdomain directory:

    RewriteRule ^page/*$ ./../page.php [L]

    If I use the rule, the address (browser) changes from subdomain.domain/page/ to domain/page.php

    RewriteRule ^page/*$ http://domain/page.php [L]

    Can anyone help me, please?

    Thank you in advance.
     
    JRJR, Dec 5, 2006 IP
  2. JRJR

    JRJR Active Member

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    Isn't this the right place to post this? :confused:
     
    JRJR, Dec 5, 2006 IP
  3. Scolls

    Scolls Guest

    Messages:
    70
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So you're wanting to have like en.domain.ext, fr.domain.ext etc, but keep most of your files in the main domain.ext directory, just having different language files in the subdomain directories?

    Why bother with rewriting url's at all? Just set the documentroot of each subdirectory to the documentroot of the domain, so that all will access the same file.

    Then use $the_subdomain = $_SERVER["SERVER_NAME"]; to see which subdomain was requsted, and include your language files accordingly?
     
    Scolls, Dec 5, 2006 IP
  4. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I believe this is the right place to post your request, as I also believe is Nintendo who can help you with this when he comes around :rolleyes:
     
    Pat Gael, Dec 5, 2006 IP
  5. JRJR

    JRJR Active Member

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    Scolls, thank you very much. What a simple solution! :D Now, I have to see how can I change the httpd.conf file of my hosting service. On my machine is working 100%.

    Thank you very much, again. :)
     
    JRJR, Dec 6, 2006 IP
  6. Scolls

    Scolls Guest

    Messages:
    70
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Pleasure, JRJR. :) If you can't come right with your hosting service, there's also another simple solution:

    Use GET! eg index.php?lang=en for english, index.php?lang=fr for french, etc. Your default language naturally doesn't need a param since you'd default it to that language anyway if (!isset($_GET("lang"))). Include language files as before...
    You could possibly set up 301's for each subdomain, and then I'd imagine the referer field should show the subdomain? Not 100% sure offhand, but might also be worth a try. Then, proceed as before. ;)
     
    Scolls, Dec 6, 2006 IP
  7. JRJR

    JRJR Active Member

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    It seems that my host service can change the document root.

    Thank you very much....also for the other solution! :D
     
    JRJR, Dec 7, 2006 IP