Sub domain to sub folder DNS help!

Hi guys,

I came across this problem…

How do I use DNS configurations to point a sub-domain to the main-domain’s sub-folder?

Right now, the sub-domain is going to its own account, instead of going to a folder within the main-account.

WHM (cPanel) has this option and can be setup automatically, but Plesk doesn’t seem to have it. It requires me to manually configure the DNS which I have no idea how to…

Please help!

Thanks!

This isn’t true, and where a domain is hosted isn’t determined by DNS configuration but by the web server configuration.

In Plesk, you go to the main domain, then click the subdomains icon and add the subdomain. It puts the subdomain’s files in /var/www/vhosts/example.com/subdomains/example/httpdocs, as well as adding the subdomain’s DNS record.

Thank you for the prompt reply! I found the link you mentioned. But, is there anyway, that the subdomain will not be its own account? I would love it to be just pointing to a subdirectory.

I would like the subdomain be in something like:

/var/www/vhosts/example.com/httpdocs/folder_for_sub_domain/

Two choices:

  1. Add the DNS entry (you just need an A record pointing to your server’s IP) yourself, and edit httpd.conf to add the VirtualHost entry to point the subdomain to a directory.

  2. Make /var/www/vhosts/example.com/subdomains/example/httpdocs a symlink to /var/www/vhosts/example.com/httpdocs/subdomain (ln -s).

I can’t access the httpd.conf even with SSH so I’m left with option #2.

I did a:

ln -s /var/www/vhosts/example.com/httpdocs/sub/ /var/www/vhosts/example.com/subdomains/sub/httpdocs

For some reason it creates a folder:
/var/www/vhosts/example.com/subdomains/sub/httpdocs/sub/

and the symbolic link didn’t work out.

But the main concern is, between the 2 admin software, there seems to be a huge difference in setting up subdomains.
In cPanel, subdomain is just an masked alias that goes to a folder inside the main domain’s “public_html”,
but in Plesk, subdomain is an actual account in which has its own “mail”, “stats”, “config”, and its own “httpdocs”.

I have also checked both websites’ DNS zones.
In cPanel, the main domain will have a line for the subdomain:
“www.subdomain / A / xxx.xxx.xxx.xxx”

In Plesk, it’d have:
subdomain.domain.com / A / xxx.xxx.xxx.xxx”

I wonder, if there’s anyway that in Plesk, the subdomain is just a simple alias that short-cuts to a folder, instead of an entire account.

cPanel:

Plesk:

I have contacted Media Temple and so far none of them techs know how to set it up the cPanel way…

Did you delete the sub/httpdocs directory before trying to create a symlink there?

They see the “subdomain” as a different account than the “main domain” so… I got a biggo erro:

Forbidden
You do not have permission to access this document.

That’s after I followed your instruction with:
[root ~]# rm -rf /var/www/vhosts/domain.com/subdomains/sub/httpdocs
[root ~]# ln -s /var/www/vhosts/domain.com/httpdocs/sub /var/www/vhosts/domain.com/subdomains/sub/httpdocs

I’m very sorry, I DO have access to httpd.conf, and this is what I did:

<VirtualHost *:80>
DocumentRoot /var/www/vhosts/domain.com
ServerAlias .domain.com
ServerName www.domain.com
RedirectMatch 301 (.
) http://domain.com$1
</VirtualHost>

Doesn’t seem to work… Since I’m not quite sure what my “root directory” is, I also tried:
DocumentRoot /var/www/vhosts/domain.com/httpdocs
DocumentRoot /var/www/vhosts/domain.com
DocumentRoot /var/www/vhosts

Nothing happens.

You’re root, you decide permissions. chown the directory?

Doesn’t seem to work… Since I’m not quite sure what my “root directory” is, I also tried:

You’re trying to make it /var/www/vhosts/example.com/httpdocs/sub. That’s the root of the website you want to serve on the subdomain, that’s the DocumentRoot.

I don’t understand the RedirectMatch. Why are you trying to redirect all requests to the main domain instead of the /sub directory?

I donno… I’m just trying to do a wildcard subdomain thing. I searched other websites but my understanding of this concept is limited.

What I’m trying to do is:

http://en.domain.com/ will read files from http://www.domain.com/en/
http://sp.domain.com/ will read files from http://www.domain.com/sp/
http://fr.domain.com/ will read files from http://www.domain.com/fr/

etc…

I already edited the DNS zone with:

*.domain.com, A, xxx.xxx.xxx.xxx

I guess now I just need to edit my httpd.conf with the right code?

Can you do proper nameserver to your domain…i think problem of the DNS!