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
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

How do I redirect all subdomains to main domain ?

Discussion in 'Plesk for Linux - 8.x and Older' started by Neantis, Dec 1, 2007.

  1. Neantis

    Neantis Guest

    0
     
    Hello,

    I manage a server for a small association, and for their new website based on a complex dymaic back end they want to redirect all requests on subdomains to the main domain. First, I thought I can add a virtual host, but I tried and I failed. So, can you describe me how to redirect all subdomains to main domain ? ( (.+)\.domain\.com$ => domain.com?sub=$1 )

    Thank you.

    PS: Sorry for my english, I'm french and I haven't seen any quality forum about plesk in my language.
     
  2. breun

    breun Golden Pleskian

    29
     
    Joined:
    Jun 28, 2005
    Messages:
    1,647
    Likes Received:
    0
    You'll need a wildcard DNS A record that maps *.example.com to the IP address of the main domain. Also setup a ServerAlias for the domain (see Including Directives into Web Server Configuration File):

    Code:
    ServerAlias *.example.com
    When this is set up all subdomains will just hit the files on the main domain.

    Then you can for instance set up a mod_rewrite rule or use some script to decide what to do depending on which subdomain was requested.
     
  3. Neantis

    Neantis Guest

    0
     
    This doesn't work :/
    What I need to add in my domain /conf/vhost.conf ?

    I have tried this :
    <VirtualHost 127.0.0.1:80>
    ServerName mydomain.com:80
    ServerAlias *.mydomain.com
    </VirtualHost>
    With this command after :
    /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=mydomain.com
    And I have a PleskFatalException which explain that Plesk can't restart apache.

    I have added the DNS record before doing all that.

    (I have changed domain and IP here, but in the reality I have entered the right data.)
     
  4. breun

    breun Golden Pleskian

    29
     
    Joined:
    Jun 28, 2005
    Messages:
    1,647
    Likes Received:
    0
    You need just that one line that I posted.
     
  5. Neantis

    Neantis Guest

    0
     
    Thank you. You help me a lot ;). This works.
     
Loading...