1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice

4 domains, 1 account, pointing to subfolders possible?

Discussion in 'Plesk for Linux - 8.x and Older' started by Garp, Aug 14, 2005.

  1. Garp

    Garp Guest

    0
     
    Hi all,

    A customer of ours has 4 domains. 1 Domain is an actual hosting account in Plesk (7.5.2) and 3 are parkings in Total Domains that point to that domain. So far, so good.

    Now the customer wants the 4 parkings to point at subfolders of his httpdocs folders like this;

    maindomain.com points to standard /httpdocs/ folder
    domain.de points to /httpdocs/de/ folder
    domain.nl points to /httpdocs/nl/ folder
    domain.be points to /hjttpdocs/be/ folder.

    How can i accomplish this? Plesk nor Totaldomains can't do it out-of-the-box, but it could be done with be done with rewrite rules, by editing the vhost.conf for that domain. Can anyone help me to enable this setup? Maybe someone has got this working already? I'm not really an apache guy; i know that it should be able to do this, but any help on setting this up would be greatly appreciated...
     
  2. jamesyeeoc

    jamesyeeoc Guest

    0
     
    Disclaimer: I have not tried this on parked domains, but in theory it should work just like redirecting subdomains.
    Theory: Since the domains are already Parked, you should only have to put this into the main domain's vhost.conf file (and vhost_ssl.conf for SSL connections). When a user browses to the parked domain, they are redirected to the main domain, then the rewrite rules are parsed and they should then be redirected to the proper directory.

    Per the 4psa manual:
    The HTTP_HOST should still remain the same as the user typed it.

    Again, I have not tested this, I am currently rebuilding my test server. Please let me know for sure.
     
  3. Garp

    Garp Guest

    0
     
    Ah, thx, super.

    Will check later if it works as you wrote down; my backup server just died and i won't be making changes to my live environment without backups present.

    Will let you know how it worked out....
     
  4. Garp

    Garp Guest

    0
     
    Hello james.

    Fantastic. Works fine except that only the

    http://domain.xx works fine and goes to the right folder..
    http://www.domain.xx goes to the standard plesk page.

    Any idea why this is happening and how to resolve that?
     
  5. jamesyeeoc

    jamesyeeoc Guest

    0
     
    Ah, just change the ServerAlias lines:

    ServerAlias domain.be www.domain.be
    ServerAlias domain.nl www.domain.nl
    ServerAlias domain.de www.domain.de

    and that should easily solve that one.

    Mod_rewrite is a great thing, but can get quite complicated depending on what your needs are. I try to keep the example code fairly simplified when possible, and often do so based on the original posted question. I sometimes forget to use my own brain about the little details.... ;)

    Here's a quick breakdown of what the commands are doing:

    <IfModule mod_rewrite.c> #Only do if we have mod_rewrite
    RewriteEngine on #Turn on the rewrite engine

    # Rewrite domain.de to /httpdocs/de
    ServerAlias domain.de www.domain.de #Match with or without the www.
    RewriteCond %{HTTP_HOST} ^domain.de$ #Check for 'domain.de' in the HOST string
    RewriteCond %{REQUEST_URI} !^/de/ #Make sure the /de/ folder was not requested directly
    RewriteCond %{REQUEST_URI} !error_docs #Make sure we are not in error page condition
    RewriteRule (.*) /de/$1 #Rewrite the location to the domain's docroot/de/ directory and append any additional part of the original URL
    </IfModule> #Close the IfModule statement
     
  6. Garp

    Garp Guest

    0
     
    We're getting there :)

    The code is as follows now;

    # Rewrite thefootballbox.de to /httpdocs/de
    ServerAlias thefootballbox.de www.thefootballbox.de
    RewriteCond %{HTTP_HOST} ^thefootballbox.de$
    RewriteCond %{REQUEST_URI} !^/de/
    RewriteCond %{REQUEST_URI} !error_docs
    RewriteRule (.*) /de/$1

    I do get a different page at the www now, bu not the right one.

    Could it be that i need to do something with the

    RewriteCond %{HTTP_HOST} ^thefootballbox.de$

    becuase that doesn't 'see' the www ?

    Pages;

    ok - http://thefootballbox.de
    not ok - http://www.thefootballbox.de

    The latter doesn't appear to go to the subdirectory.

    Behaviour is the same for all domains.
     
  7. jamesyeeoc

    jamesyeeoc Guest

    0
     
    I did not test this, and I am terrible at REGEX, but you may want to try something like:

    RewriteCond %{HTTP_HOST} ^(www\.)?(([^\.]+)\.){1}thefootballbox\.de$

    This says "The domain can optionally have a 'www.' in front of it. It should then have a string of characters without a period in them that can be any length. This should be followed by a period. This entire group (the string of characters followed by the period) should occur exactly once. It should be followed by 'domain.com' with 'domain.com' being at the end of the domain string." If these criteria are not met, we won't proceed.

    I have never had to put a \ in the 'domain.com' portion, so I'm not sure if that one is needed. The others in the first half of the line are needed.

    I found this in another thread from Plesk 5.0 and should not be Plesk version specific:

    http://forum.plesk.com/showthread.php?threadid=6778
     
  8. Garp

    Garp Guest

    0
     
    Now the entry without the www fails :)

    Code;

    # Rewrite thefootballbox.de to /httpdocs/de
    ServerAlias thefootballbox.de www.thefootballbox.de
    #RewriteCond %{HTTP_HOST} ^thefootballbox.de$
    RewriteCond %{HTTP_HOST} ^(www\.)?(([^\.]+)\.){1}thefootballbox\.de$
    RewriteCond %{REQUEST_URI} !^/de/
    RewriteCond %{REQUEST_URI} !error_docs
    RewriteRule (.*) /de/$1

    This is harder that i thought. The simple redirect i can 'read', but this second is a little bit to hard for me.
     
  9. Garp

    Garp Guest

    0
     
    Okay, fixed it.

    Code;


    # Rewrite thefootballbox.de to /httpdocs/de
    ServerAlias thefootballbox.de www.thefootballbox.de
    RewriteCond %{HTTP_HOST} ^thefootballbox.de$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.thefootballbox\.de$
    RewriteCond %{REQUEST_URI} !^/de/
    RewriteCond %{REQUEST_URI} !error_docs
    RewriteRule (.*) /de/$1


    ...works fine for the www and the plain url. Found this [OR] statement info at http://forum.inmotionhosting.com/viewtopic.php?p=361

    All i want to ask now is why changing the line after [OR] to;

    RewriteCond %{HTTP_HOST} ^*\.thefootballbox\.de$

    doesn't work. It should get all entries before the . wouldn't it? Is there any way to make it catch all the mistypes before the .domain.xx as well?
     
  10. xtended

    xtended Guest

    0
     
    how to...

    if i have no mod_rewrite?
     
  11. xtended

    xtended Guest

    0
     
    so.. i got mod_rewrite and everything works fine, but...

    the images in my subfolder are not shown because there path is not absolute:

    imgs are in /httpdocs/images.

    the mod_rewrite points now my domain example2.com to /httpdocs/folder2/ and
    now the file tries to find any images in
    /httpdocs/folder2/images/ instead of
    /httpdocs/images.

    what can i do without having change all paths?
     
  12. jamesyeeoc

    jamesyeeoc Guest

    0
     
    If your site code has hard paths, then there is not much you can do but change the hard paths to relative paths.

    In other words, change the embedded paths from /httpdocs/images to ./images
     
  13. xtended

    xtended Guest

    0
     
    right now, the path for example is ../../images/flash/start.swf

    ../../images/test.jpg works bot not the flash file. if i write http://example.com/images/flash/start.swf it does - but it's not very connvenience to have to change all paths in every file.

    so there must be a proper solution, isn't it?
     
  14. jamesyeeoc

    jamesyeeoc Guest

    0
     
    You could either put more rewrite statements, or try using the mod_alias directives to change requests for /httpdocs/folder2/images to /httpdocs/images.
     
Loading...