• 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

Subdomains and www host

P

pran

Guest
When a domain admin creates a subdomain, Plesk doesn't create a `www' host and also doesn't have any ServerAlias entry in the domain's httpd.include file. Is this normal by design?
 
Domain config issue

When you create a domain, there is a checkbox next to 'www', if it is not check marked, then Plesk will not do the 'www' option.

If you already have domain(s) defined, you can go back into it's settings and put a checkmark.
 
Thanks for the reply but my question is about subdomains, not the main domain.
 
Sorry, I mis-read your post. However, in answer to your question, Plesk does not add a 'www' for any subdomains which are created, nor does the 4PSA product.

I think their mindset is that there should not be a 'www' before the subdomain and so they have never addressed this issue, which has existed in previous major versions as well.

Interestingly, in Plesk 6, there were no warnings about modifying the httpd.include file. Now in Plesk 7 Reloaded (at least in 7.5.2) there is a large warning at the top of the file.... They want us to only use the vhost.conf file for any mods...
 
Workaround is done by manually editing the vhost.conf file for the main domain.

If you want to alias 'www.sub.domain.com'
then put into the vhost.conf -

ServerAlias www.sub.domain.com
RewriteCond %{HTTP_HOST} ^www.sub.domain.com$
RewriteCond %{REQUEST_URI} !^/subdomains/sub/
RewriteCond %{REQUEST_URI} !error_docs
RewriteRule (.*) /subdomains/sub/$1

This would go between the IfModule tags.

Remember to change references to 'sub' and 'domain' and 'com' to whatever you really have it named.
 
Sorry I would have been more specific up front, but lately the posters have not wanted a 'manual' workaround, but a control panel fix....

Normally this file is in -

/home/httpd/vhosts/domain.com/conf/vhost.conf

or for the SSL one -

/home/httpsd/vhosts/domain.com/conf/vhost.conf
 
I wasn't able to find vhost.conf but I found an instruction in the httpd.include file:
Code:
# ATTENTION!
# DO NOT MODIFY THIS FILE OR ANY PART OF IT. THIS CAN RESULT IN IMPROPER PLESK
# FUNCTIONING OR FAILURE, CAUSE DAMAGE AND LOSS OF DATA. IF YOU REQUIRE CUSTOM
# MODIFICATIONS TO BE APPLIED TO THE CONFIGURATION, PLEASE, PERFORM THEM IN THE
# FOLLOWING FILE(S):
# /home/httpd/vhosts/domain/conf/vhost.conf
# /home/httpd/vhosts/domain/subdomains/<subdomain-name>/conf/vhost.conf
How is vhost.conf merged with httpd.include? For example, I want to modify the sub-domain part of httpd.include, so I would create a vhost.conf file inside the folder of the sub-domain (as stated in the instruction) and put all the modifications there? Do I need to re-define what is already in the VirtualHost section?
 
Again, my apologies, there are several threads with this topic, and I thought this had already been covered.

You do *not* want to do this in the httpd.include file. Plesk overwrites this file.

If the vhost.conf does not exist, then you will have to create a new file.

If the vhost.conf file does not exist, then make sure you have already created a subdomain in the Plesk CP first, and verify if the file then exists.

Otherwise put the following text into a new file and save it as vhost.conf

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteMap lowercase int:tolower
ServerAlias www.sub.domain.com
RewriteCond %{HTTP_HOST} ^www.sub.domain.com$
RewriteCond %{REQUEST_URI} !^/subdomains/sub/
RewriteCond %{REQUEST_URI} !error_docs
RewriteRule (.*) /subdomains/sub/$1
</IfModule>

Of course, change all references to the actual sub and domain you are creating.

Too many days and nights without sleep, too many posts in too many forums to keep track of....
 
Eureka! I created a vhost.conf file inside the conf folder of the subdomain with the line:
Code:
ServerAlias [url]www.subdomain.domain.com[/url]
and presto, it worked! (of course, after reloading the web server's configuration file). The full instructions on how to do this can be found here. Thanks james!
 
Back
Top