i want to setup a virtual host to the url of with some port
e.g. my server name is rockstar.net
so i want to setup a subdomain on my server.where i should access the content of http://rockstart.net:8001/
what i tried :
<VirtualHost *>
ServerName content.rockstart.net
DocumentRoot "http://rockstart.net:8001/"
</VirtualHost>
which is giving error
Warning: DocumentRoot [/etc/apache2/http:/rockstar.net:8001/] does not exist
The DocumentRoot points to the folder in the local folder structure where the site is hosted, e.g. (on a linux system) /var/www/html/rockstart.net. The port number must be included in the VirtualHost definition. Therefore your VHost definition should rather look like:
However, this will still require the users to enter http://rockstart.net:8001 into their browser. I suspect what you had in mind was actually more like a redirection. If the redirection needs to include a change of port (i.e. from 8001 to 80) then you either need to use a reverse proxy or a DNAT firewall.
Or, if the content that is to be made available under http://content.rockstart.net is located on the same server where rockstart.net is located, you could simply use a
redirection within the file system. However, in that case I wonder why you don't just point content.rockstart.net at the same location where rockstart.net:8001 gets its content from?
The
DocumentRoot
directives describes the physical path on the machine, like/var/www/myvhost.net
.Set this directive as a path and use
ServerName
for the first andServerAlias
for every other name you want to point to your files, defined inDocumentRoot
.