Forum Moderators: phranque

Message Too Old, No Replies

Two websites on one machine!

         

wanted45000

10:28 pm on Oct 9, 2009 (gmt 0)

10+ Year Member



Hello, i have the question, i was searching answer at internet and i didn't find, i hope you will help me.

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/***) ?

g1smd

10:33 pm on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use a rewrite.

There are a very large number of prior postings explaining how to do this.

caribguy

12:32 am on Oct 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you're asking about Name Based Virtual Hosts [httpd.apache.org]. Apache has very extensive documentation, but I guess that not knowing what something is called makes it a bit difficult to search for it :)

This might help to get you started...

wanted45000

6:03 am on Oct 10, 2009 (gmt 0)

10+ Year Member



Thanks caribguy i for real didn't know how that option is called :)

wanted45000

8:52 pm on Oct 10, 2009 (gmt 0)

10+ Year Member



hmm, i find problem..

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]

caribguy

3:24 am on Oct 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A smart thing to do first is to take your log files out of the document tree that can be accessed from outside: change your path to C:\xampp\wow.example.org.access.log" or something to that effect. As a matter of fact, c:\logfiles\wow.access.log would be preferred.

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!

Caterham

10:36 am on Oct 12, 2009 (gmt 0)

10+ Year Member



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