• 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 domain to subdirectory of different domain

G

gweilo8888

Guest
Hi all

I have a feeling the following is possible, with editing of vhost.conf - but I'm not sure how to achieve it. Thoughts?

What I have:

* Root access to dedicated server running CentOS3.6 and Plesk8
*Two domains. One currently in use with physical hosting, the other idle and unconfigured. We'll call them domain1.com and domain2.com.

What I need to do:

* domain1.com continues to function normally as it always has
* domain2.com redirects to domain1.com/subdirectory/

What I'd like to happen:

* When you go to domain2.com, it should preferably remain in the browser bar for the first page served from domain1.com/subdirectory without cheating and using frames
* Both domain2.com and www.domain2.com should forward to the subdirectory of domain1 (doesn't matter if the former forwards to domain1.com/subdirectiroy and the latter to www.domain1.com/subdirectory though)

For bonus points:

* Ideally, subdomain.domain2.com should forward to domain1.com/subdirectory/subdomain, if that's at all possible

The less manual editing of files each time a new subdomain is added, the better (ie. ideally I wouldn't need to physically add a subdomain, just anything.subdomain2.com would automatically go to subdomain1.com/subdirectory/anything without intervention from me after initial setup

What of this is possible, and how can I achieve it? :)

Thanks in advance for any help...
 
Thanks...

I had found and read those threads, but had a few issues:

* the first thread refers to domains being parked in 4PSA first - I don't have 4PSA, just Plesk 8. Where do I configure the extra domains in Plesk 8? As fully hosted domains? Domain aliases?

* AFAICT, the method there won't keep the domain in the browser bar

* AFAICT, I'd need to manually edit vhost.conf every single time I wanted to add a new subdomain, eg. if I had set up subdomain1.domain2.com and subdomain2.domain2.com to return www.domain1.com/subdomain1 and www.domain1.com/subdomain2, and then over the following weeks I needed to subdomain3 through to subdomain84, I'd have to go back and manually edit vhost.conf every single time a new subdomain was added. I'd *really* like to be able to just say something like *.domain2.com return to www.domain1.com/*

Can anybody figure a way to extend the info in the thread jamesyeeoc linked to achieve any of this?
 
Doesn't matter if you have 4PSA or not.

See the second thread URL I edited. Then use [L,P] instead of the [L,R]

As for your 3rd point, write a script to do the modifications for you, then set the script to run upon subdomain creation in the control panel. Or, read up on the mod_rewrite docs at apache.org and modify the posted code to do the 'auto' thing.
 
Doesn't matter if you have 4PSA or not.

OK, I'm just a little confused as to where I configure the second domain in Plesk...

See the second thread URL I edited. Then use [L,P] instead of the [L,R]

Great - and that will redirect while keeping the domain, without cheating and using frames? That's what I am hoping for...

As for your 3rd point, write a script to do the modifications for you, then set the script to run upon subdomain creation in the control panel. Or, read up on the mod_rewrite docs at apache.org and modify the posted code to do the 'auto' thing.

OK - I'm not very good at this, but I can certainly try some more. ;)
 
OK, I'm just a little confused as to where I configure the second domain in Plesk...
You create the 2nd domain in the control panel, setup for physical hosting. (Just like you did for the first domain)

Then in that domain's /conf folder, you create a vhost.conf file with the mod_rewrite stuff in it.
(example: /home/httpd/vhosts/seconddomain.com/conf/vhost.conf
or
/var/www/seconddomain.com/conf/vhost.conf)
where ever your particular distro and Plesk setup is storing the domain's files...

Then you would do the websrvmng command and restart apache (see the other thread for more details)

Now, if I had the Universal Remote from 'Click', then I would have more than enough time to write all the script utilities that I would ever need to further supplement Plesk's CP....
 
Gotcha, thanks. Been up all night, but I'll try this soon and report back. :)
 
Back
Top