• 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

Subdomain Redirect To Directory

A

aviddv1

Guest
Hey there,

I've got Plesk 8 and I spent hours looking around for an answer as to how I can redirect a subdomin to a directory in the domain.

Seems I found a solution so I figured I'd post it just in case anyone else is looking for an answer.

First thing I did was edit the httpd.include file in the main domain's conf directory. Under the virtual host tag for the subdomain for port 80, I added this line right before the close tag:

include /var/www/vhosts/(domain)/subdomains/(subdomain)/conf/vhost.conf

Then in the subdomain's conf directory I created a file called vhost.conf.

Inside the vhost.conf file I added the following:

DocumentRoot /var/www/vhosts/(domain)/httpdocs/(destination folder)

<Directory /var/www/vhosts/(domain)/httpdocs>
<IfModule sapi_apache2.c>
php_admin_value open_basedir "/var/www/vhosts/(domain)/httpdocs/(destination folder):/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_value open_basedir "/var/www/vhosts/(domain)/httpdocs/(destination folder):/tmp"
</IfModule>
</Directory>

The vhost.conf file tells apache that the root of the subdomain is the destination folder and then assigns the php base directory as the destination folder.

Don't forget to:
/usr/local/psa/admin/bin/websrvmng -u --vhost-name=(domain)

and restart apache:
/sbin/service httpd restart

Hope this helps.

Thanks,
Ward
 
There's no need to manually add the include in httpd.include. Just create the conf/vhost.conf file and run websrvmng afterwards. By the way, I think I would have used mod_rewrite for this.
 
I tried it without the mod to httpd.include, but it wouldn't execute anything in the subdomain's vhost.conf.

What's the difference what I did and mod_rewrite?

I'm very nice at this.

Thanks,
ward
 
Just create vhost.conf in the conf dir, run websrvmng (which will add the include statement) and reload apache. With mod_rewrite you can dynamically, well, rewrite URLs without altering the DocumentRoot and having to mess with open_basedir settings and things like that.
 
Wow, this is terrible. We are using Plesk 7.x for Windows and I'm looking for an answer to Virtual Directories in Plesk/Linux and came across this post. Is it really this much of a hassle to create a Virtual Directory in Plesk/Linux?

In Plesk/Windows, you simply add a new domain, select Standard Forward for hosting, and type the path (FQDN).

We actuall have this on our server right now. For example;

products.uscomputergroup.com -> forwards to -> http://www.uscomputergroup.com/products/

hosting.uscomputergroup.com -> forwards to -> http://www.uscomputergroup.com/hosting/

Also, is there no way of making a simple Virtual Directory in Plesk/Linux!?!?!? For example;

domain.com/servers -> is virtually -> domain.com/products/hardware/servers

This seems WAY too simple. Windows has done this in IIS for as long as I can remember. So do I need to write these rediculous .htaccess scripts when using a nix box?
 
Keep in mind that Windows is supposed to make things easy, so the human user doesn't have to really know anything about what goes on in the lower levels of the OS. *nix is basically a command line driven OS, which you *can* if desired, add a GUI on top.

The simple answer is: you can write scripts or webpages to do this stuff, or you can just do it by hand. It would be nice if SWSoft were to incorporate many of these things into the control panel, but so far, they just haven't done it. I am sure there are many admins who have done so to make their lives simpler, but many still do it by hand.

My last comment is: I used to setup/maintain IIS servers all the time, but I also ended up spending way too much time keeping them secured, disinfected, and running. With *nix servers, I spend way much more time doing other stuff, even fun stuff now.
 
Originally posted by aviddv1
I've got Plesk 8 and I spent hours looking around for an answer as to how I can redirect a subdomin to a directory in the domain.
Sorry you spent so much time searching. I'm pretty sure I covered doing that with mod_rewrite some time ago in the Plesk 7.5 forums (or 7.x). Glad you found a solution which works.
 
No offense to anyone here, as we all probably have "been there done that" when it comes to administrating servers.

But, if we all didn't truely like the convenience of having a "GUI" of some sort, we wouldn't be using Plesk. We all know how to edit .conf files.

The simple truth is, we're not doing this as a hobby anymore, it's a job (for most of us I take it). And, anything that can make my job easier and more efficient, allowing me to get more done in less time, is a welcomed accommodation.

It's not the juvenile, age old debate of OS prowess anymore. I could care less if the machine is a nix box, winders box, or a Ti-80, as long as it gets the job done and does what I need it to--- kudos!

So, with all that said, "Plesk, please add Virtual Directory support to Plesk for Linux!"
 
You can also use the free script url2subdomain located at http://www.gitme.net/php/

you need to put a serveralias in vhost.conf and a wildcard dns A record, both can be automated.

The advantage is that you dont need to mess with the setup behind the screens and its not default for everybody. Only people that want it need to install the script.

regards
Jan
 
Back
Top