1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice

Redirect subdomain to domain?

Discussion in 'Plesk for Linux - 8.x and Older' started by gweilo8888, Oct 28, 2005.

  1. gweilo8888

    gweilo8888 Guest


    I'm in the process of moving from shared hosting to a dedicated server running CentOS with Plesk 7.5 Reloaded. I have several domains I am transferring across.

    For one of my domains, I used to host a site at a subdomain which later moved to its own, separate domain. On my shared hosting with cpanel, I could set up a subdomain redirect which would forward anybody arriving at that subdomain to the new domain, keeping the same directory structure.

    For example, if you were to arrive at:


    You would be transferred to:


    What would be the best way to accomplish the same task with Plesk?

    Many thanks in advance for the help...
  2. ShadowMan@

    ShadowMan@ Guest

    I would setup the subdomain under domain1.com, then use mod_rewrite statements to redirect to the proper domain2 site. You could try using the following which was written for another forum user with a similar situation:
    # vhost.conf for [url]http://sub.thisdomain.tld[/url]
    #    File: /home/httpd/vhosts/thisdomain.tld/conf/vhost.conf
    # test for forum user to redirect/rewrite from [url]http://sub.thisdomain.tld[/url] to [url]http://sub.otherdomain.tld/dir/[/url]$1
    # Need change 
    #    from ~/vhosts/thisdomain.tld/subdomains/sub/httpdocs/index.html
    #     to ~/vhosts/otherdomain.tld/subdomains/sub/httpdocs/dir/index.html
    # This will be a simple 'close' example, maybe not the *exact* you need, but should help get you
    # on your way to the finished product.
    <IfModule mod_rewrite.c>
    RewriteEngine on
    ServerAlias sub.thisdomain.tld
    # Rewrite sub.thisdomain.tld/index.html to sub.otherdomain.tld/dir/index.html
    AliasMatch /index(.*) /home/httpd/vhosts/otherdomain.tld/subdomains/sub/httpdocs/dir/index.html
    Change it to suit your needs. This assumes that both domains are on the same Plesk server.

    Note: before I step on anyone's toes, credit for this goes to jamesyeeoc.