: Pointing a subdomain (subdomain.example.com) to a subfolder (example.com/subfolder)? I want my subdomain subdomain.example.com to load content from a subfolder on the root domain example.com/subfolder.
I want my subdomain subdomain.example.com to load content from a subfolder on the root domain example.com/subfolder.
So if a user goes to subdomain.example.com/?article=hey it should load the content from domain.com/subfolder/?article=hey.
Web server: Apache
More posts by @Kaufman445
1 Comments
Sorted by latest first Latest Oldest Best
If you are using Apache then you can simply create an additional VirtualHost for your sub domain and set the webroot to the directory you choose.
Example:
Your current VirtualHost is most likely something along the lines of the following; with the ServerName your domain and the DocumentRoot being the web root.
<VirtualHost 1.2.3.4:80>
ServerName example.com DocumentRoot "/www/domain"
</VirtualHost>
You could create another VirtualHost with the ServerName as the sub domain and the DocumentRoot as the sub folder you want to use such as this:
<VirtualHost 1.2.3.4:80>
ServerName subdomain.example.com
DocumentRoot "/www/domain/subfolder"
</VirtualHost>
Now when you access subdomain.example.com in your browser it would load the content from /www/domain/subfolder. Keep in mind that in this example you would still be able to access the sub folder by going to example.com/subfolder since the sub folder is still within the first VirtualHosts DocumentRoot.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.