Forum Moderators: phranque

Message Too Old, No Replies

1 home apache serve 2 ip 3 purchased domains help

Need help getting Domain names to correct pages

         

jcmorse563

7:27 pm on Feb 19, 2011 (gmt 0)

10+ Year Member



I've really been stuggling with this setup. I have purchased three domain names, one from enom and two from cheapnames.
I have one ip address and am running on apache 2.x Xampp version. I have set up the vhosts with named servers. when I run
httpd -S i recieve this setup Please note that "Domainx" has beed substituded for my actual names. for some reason nomatter
which domain name i address to i go to the default web page, uless i do it locally, what am i missing?

httpd -S readout
Setting environment for using XAMPP for Windows.

admin@JEFFERYMORSEMIN C:\xampp
# httpd -S
VirtualHost configuration:
127.0.0.1:80 is a NameVirtualHost
default server Domain1.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:51)
port 80 namevhost Domain1.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:51)
port 80 namevhost Doamin2.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:67)
port 80 namevhost mail1.Domain2.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:86)
port 80 namevhost Domain3.com (C:/xampp/apache/conf/extra/httpd-vhosts.conf:104)
wildcard NameVirtualHosts and _default_ servers:
_default_:443 localhost (C:/xampp/apache/conf/extra/httpd-ssl.conf:80)
Syntax OK

admin@JEFFERYMORSEMIN C:\xampp

In httpd.conf
I have un commented include vhosts.conf

However if i comment out the default within httpd.conf the system doesn't work so i change the default to one of the
vhosts domain3.com and localy if i type in http:\\domainX.com we go to the correct page. but if on the net if i type
in it goes to the default page of www.domain3.com even though it shows the url in the address bar correctly


vhost.conf
NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
ServerAdmin postmaster@Domain1.com
DocumentRoot "C:\xampp\www\domain1.com\htdocs"
ServerName domain1.com
ServerAlias www.domain1.com
CustomLog "C:\xampp\www\domain1.com\htdocs\access.log" combined
ErrorLog "C:\xampp\www\domain1.com\htdocs\error.log"

<Directory "C:\xampp\www\domain1.com\htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
ServerAdmin postmaster@domain2.com
DocumentRoot "C:\xampp\www\domain2.com\htdocs"
ServerName domain2.com
ServerAlias www.doamain2.com
CustomLog "C:\xampp\www\domain2.com\htdocs\access.log" #combined
ErrorLog "C:\xampp\www\domain2.com\htdocs\error.log"


<Directory "C:\xampp\www\\domain2.com\htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



<VirtualHost 127.0.0.1:80>
ServerAdmin postmaster@mail1.com
DocumentRoot "C:\xampp\www\mail1"
ServerName mail1.maildomain.com
ServerAlias www.mail1.maildomain.com
CustomLog "C:\xampp\www\mail1\access.log" combined
ErrorLog "C:\xampp\www\mail1\error.log"

<Directory "C:\xampp\www\mail1">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>



<VirtualHost 127.0.0.1:80>
ServerAdmin postmaster@domain3.com
DocumentRoot "C:\xampp\www\domain3.com\htdocs"
ServerName domain3.com
ServerAlias www.domain3.com
CustomLog "C:\xampp\www\domain3.com\htdocs\access.log" #combined
ErrorLog "C:\xampp\www\domain3.com\htdocs\error.log"

<Directory "C:\xampp\www\doamain3.com\htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


my hosts file in system32 xp

127.0.0.1
127.0.0.1 localhost
127.0.0.1 Domain3.com
127.0.0.1 quickstart.localhost #this for Zend local server
127.0.0.1 mail1.maildomain.com
127.0.0.1 domain2.com
127.0.0.1 domain1.com


my .htaccess file which is in the default htdocs folder of the comp which is domain3.com/htdocs
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/domain1.com/
RewriteCond %{HTTP_HOST} ^(www\.)?domain1.com\.
RewriteRule ^(.*)$ domain1.com/$1 [L]

RewriteCond %{REQUEST_URI} !^/domain3.com/
RewriteCond %{HTTP_HOST} ^(www\.)?domain3.com\.
RewriteRule ^(.*)$ domain3.com/$1 [L]

RewriteCond %{REQUEST_URI} !^/domain2.com/
RewriteCond %{HTTP_HOST} ^(www\.)?domain2.com\.
RewriteRule ^(.*)$ domain2.com/$1 [L]

jdMorgan

5:21 pm on Mar 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In such an application, using .htaccess to 'map' domains to filespaces is really complicating things and wasting CPU time.

I'd suggest that your simply point your various domains into the filespace by using name-based virtual servers and the DocumentRoot directive as intended. This will *really* simplify your life as far as on-going site development and maintenance is concerned.

Using mod_rewrite to implement mass-virtual-hosting is really a last-ditch solution for those cases where no other solution is possible. It complicates all future .htaccess code because all external redirects must be handled in the 'main' .htaccess file before any internal rewrites can be invoked in order to prevent exposing filepaths as URLs. Because all requests for all domains must be processed through all redirect rules, this becomes inefficient and cumbersome to maintain.

If you haven't already done so, review the name-based virtual servers tutorial at apache.org. I also suggest simplifying your life by setting up only two domains to begin with, add the third one later.

Jim

jcmorse563

6:12 pm on Mar 4, 2011 (gmt 0)

10+ Year Member



I don't really know what i changed but i got them working and to be honest im a little afraid to change anything.. I first attemp was for simple named v-host but it always would default to the primary default page.. i look agian at the tutorial. thanx for your reply