I have domain on one server mydomain.com There is subdomain on that server subdomain.mydomain.com That subdomain should point to other server to public_html/myfolder. Please advise how to do that.
Asked
Active
Viewed 128 times
-3
-
1You need to try yourself first and then come here to ask if you encounter any issues. – Tero Kilkanen Feb 20 '17 at 12:49
1 Answers
1
You'll need to edit/create a Virtualhost file for your subdomain. The virtualhost for Apache should look like bellow.
<VirtualHost XX.XX.XX.XX>
DocumentRoot "/www/public_html"
ServerName subdomain.example.com
ServerAlias www.subdomain.example.com
# Other directives here ...
</VirtualHost>
Edit: Name based virtual hosting.
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com *.example.com
DocumentRoot /www/public_html/main_website
</VirtualHost>
<VirtualHost *:80>
ServerName www.example2.com
DocumentRoot /www/public_html/subdomain
</VirtualHost>
NginX
server {
listen 80;
listen [::]:80;
root /var/www/public_html/subdomain;
index index.html index.htm index.nginx-debian.html;
server_name subdomain.example.com www.subdomain.example.com;
location / {
try_files $uri $uri/ =404;
}
}

Rapsoulis
- 85
- 1
- 6
-
What happens if the OP is using nginx? Or if they are using name based virtual hosting ? – user9517 Feb 20 '17 at 14:10