Forum Moderators: phranque
I want to create two websites on one machine example:
I have domain name 123.com and i have sub-domain ***.123.com,
now at my PC are two websites in folder htdocs/index.php and htdocs/***/index.php, if i want to connect to first website (123.com) i use domain name 123.com , but if i want connect to other website i need to write like that 123.com/*** or sub-domain ***.123.com/*** , how i can connect to second website with sub-domain, without folder writing (***.123.com/***) ?
This might help to get you started...
i find this script:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost wow.example.org>
DocumentRoot "C:\xampp\htdocs\lichking"
ServerName wow.example.org
CustomLog "C:\xampp\htdocs\lichking\wow.example.org.access.log" combined
ErrorLog "C:\xampp\htdocs\lichking\wow.example.org.error.log"
<Directory "C:\xampp\htdocs\lichking">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
for me this script is working well (without problems) but for others not, when others try to connect to wow.example.org then they are redirected to my intro page (game-motion.example2.lv) but when i try to connect to wow.example.org then all is good and i'm at other website, were is a problem?
[edited by: jdMorgan at 10:49 pm (utc) on Oct. 10, 2009]
[edit reason] example.org, etc, [/edit]
Use <VirtualHost 11.22.33.44:80> (the external ip address of your server) in both cases
Below it, add a "ServerName" directive, which should be different for each server... e.g. www.example.com and wow.example.com
Also, consider moving both sites to the same level, e.g.
c:\xampp\htdocs\site_one
c:\xampp\htdocs\site_two
Finally, it is not mandatory to have the <Directory> section inside of <VirtualHost>
You'll end up with something very similar to:
<VirtualHost 11.22.33.44:80>
ServerName www.example.com
DocumentRoot c:\xampp\htdocs\site_one
CustomLog "c:\logfiles\www.access.log" combined
ErrorLog "c:\logfiles\www.error.log"
</VirtualHost>
<Directory "c:\xampp\htdocs\site_one">
..your options and access rules here
</Directory>
<VirtualHost 11.22.33.44:80>
ServerName wow.example.com
DocumentRoot c:\xampp\htdocs\site_two
CustomLog "c:\logfiles\wow.access.log" combined
ErrorLog "c:\logfiles\wow.error.log"
</VirtualHost>
<Directory "c:\xampp\htdocs\site_two">
..your options and access rules here
</Directory>
Good luck!
Use <VirtualHost 11.22.33.44:80> (the external ip address of your server) in both cases
For name-based virtual hosting a NameVirtualHost directive is mandatory. Otherwise you'll have IP-based virtual hosts and you'll always end up in host #1 because you have just one IP.
NameVirtualHost 11.22.33.44:80