Issue
Lets say, i have 3 domain names
domain1.com
domain2.com
domain3.com
All @ records currently go to my server, resolving to root/index.php
.
Currently, i redirect each domain to different sub-folders with header redirects within index.php. So each url looks like
http://domain1.com/new_root1/index.php
http://domain2.com/new_root2/index.php
http://domain3.com/new_root3/index.php
Not very pretty.. but it works.
I am trying to configure my server to redirect with httpd.conf
. What i would like is have domain1 and domain2 resolve:
http://domain[*].com/index.php
on local ip 192.168.0.101:80
and domain3 resolve:http://domain3.com/index.php
on local ip 192.168.0.100:1979
There is plenty of documentation, tutorials,etc, but nothing seems to fit this..
I have looked at .htacess. Preferred comments are to use httpd.conf
. Searched Apache docs.
All attempts fail.
Where do i look? Tx in advance
Solution
With basic name based vhost configuration all of the domains will use port 80 and work as expected. You can set httpd.conf to load all individual .conf files in a particular folder and then add individual .conf files to that folder, each containing 1 vhost definition.
Near the bottom of my apache2.conf I added:
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# Include all my projects vhost conf files:
Include /vagrant/vhosts/*.conf
And in the folder I specified for loading my project vhost conf files I add a bunch of .conf files that look like this:
<VirtualHost *:80>
ServerName www.demo.vm
ServerAlias demo.vm
DocumentRoot /vagrant/htdocs/demo.vm/public
<Directory /vagrant/htdocs/demo.vm/public>
Require all granted
Options Indexes FollowSymLinks
</Directory>
SetEnv APPLICATION_ENV "development"
</VirtualHost>
If this is a local server you would have to edit your operating system hosts file to point your custom domain to the localhost.
Answered By - thinsoldier Answer Checked By - Terry (WPSolving Volunteer)