• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Redirect subdomain to domain?

G

gweilo8888

Guest
Hi

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:

http://subdomain.domain1.com/ilike/pie.htm

You would be transferred to:

http://www.domain2.com/ilike/pie.htm

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

Many thanks in advance for the help...
 
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:
Code:
# 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

</IfModule>
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.
 
Back
Top