Forum Moderators: phranque

Message Too Old, No Replies

I run 2 domains how do I redirect

Apache front index.html.en to 2 domains?

         

WiseWombat

3:20 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



Hi I have 2 registered domains running on my apache server.
My question is how do I set up my apache index to redirect to Two domains? I dont now can this be done .
At the moment I have it set so that the enters the apache index the visitors simply clicks the desired website link being eather
wisewombat.com.au/welcome.html
or Butterflyworld.com.au/butterflies/
I would like to have it set that when a visitor enters say wisewomat.com.au apache redirected them to the welcome.html page and also when a visitor enter on butterflyworld.com.au they enter the main website and not the apache index introductions page.
Any help would be great.
Also My knowlage in apache is very limited so any detailed help would be greatly apresiated. Thanks.

j4mes

3:44 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



Hi,

You need to modify your httpd.conf file to include virtual hosts.

Example:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /www/example
ServerAdmin webmaster@example.com
</VirtualHost>

Read more here: [httpd.apache.org...]

J.

WiseWombat

4:52 pm on Jun 28, 2005 (gmt 0)

10+ Year Member



At the moment My httpd.conf file is set as have this.

What do you think?
#<VirtualHost *:80>
#ServerAlias butterflyworld.com.au *.butterflyworld.com.au
#DocumentRoot /Program Files/Apache Group/Apache2/htdocs/butterflies/
#</VirtualHost>
#<VirtualHost *:80>
#ServerName www.wisewombat.com.au
#DocumentRoot /Program Files/Apache Group/Apache2/htdocs/OurShop/
#</VirtualHost>

j4mes

6:11 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



That looks fine from here, except that you need to have a ServerName in the first one (ServerAlias is for all the others) and remove all of the #'s out of it, since they're comment marks so Apache will ignore everything on the line with them!

ServerName www.example.com
ServerAlias example.com, *.example.com

Then apachectl restart (restart Apache) and see what happens!

Best of luck,

J.

WiseWombat

12:35 am on Jul 1, 2005 (gmt 0)

10+ Year Member



Thanks for your reply I tried to uncomment as you instructed but then the server fails to start.
the best I could do is.

#NameVirtualHost Wisewombat.com.au
<VirtualHost wisewombat.com.au:80>
# ServerName www.wisewombat.com.au
# DocumentRoot /Program Files/Apache Group/Apache2/htdocs/OurShop/
# ServerAlias *.butterflyworld.com.au
# DocumentRoot /Program Files/Apache Group/Apache2/htdocs/butterflies/
</VirtualHost>

But this still doesnt change the way a visitor accesses the websites.
Do you require some kind of redirect in the apache index for it to work? Im still lost?
Any other ideas thanks.

j4mes

9:32 am on Jul 1, 2005 (gmt 0)

10+ Year Member



You're still commenting out the lines you've written.

# Apache
# will
# commpletely
# ignore
# this
# stuff
but
will
read
this

change

#NameVirtualHost Wisewombat.com.au
<VirtualHost wisewombat.com.au:80>
# ServerName www.wisewombat.com.au
# DocumentRoot /Program Files/Apache Group/Apache2/htdocs/OurShop/
# ServerAlias *.butterflyworld.com.au
# DocumentRoot /Program Files/Apache Group/Apache2/htdocs/butterflies/
</VirtualHost>

to

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.wisewombat.com.au
ServerAlias *.wisewombat.com.au
DocumentRoot /Program Files/Apache Group/Apache2/htdocs/OurShop/
</VirtualHost>

<VirtualHost *:80>
ServerName www.butterflyworld.com.au
ServerAlias *.butterflyworld.com.au
DocumentRoot /Program Files/Apache Group/Apache2/htdocs/butterflies/
</VirtualHost>

and it should work as-is :-)

J.

WiseWombat

3:33 am on Jul 2, 2005 (gmt 0)

10+ Year Member



I have tried that I dont now why but if I uncomment anything inbetween ,<virtualhost> and </virtualhost> the server just fails to start

WiseWombat

3:55 am on Jul 2, 2005 (gmt 0)

10+ Year Member



If its any help im running apache 2.0.49

WiseWombat

3:57 am on Jul 2, 2005 (gmt 0)

10+ Year Member



sorry that should be 2.0.54

j4mes

10:43 am on Jul 2, 2005 (gmt 0)

10+ Year Member



Do you think you could sticky me your entire httpd.conf file and I'll look it over for you?

Always up for a challenge :-)

J.

WiseWombat

12:24 pm on Jul 2, 2005 (gmt 0)

10+ Year Member



Yes I'll do that.
I think I have sorted part of the problem out.
I changed the Document root directory folder tree and then uncommented the line, and the server starts and runs but it still wont direct to the disired directories.

NameVirtualHost wisewombat.com.au
<VirtualHost wisewombat.com.au:80>
ServerName www.wisewombat.com.au
DocumentRoot /htdocs/OurShop/
</VIRTUALHOST>
<VIRTUALHOST>
ServerAlias butterflyworld.com.au *.butterflyworld.com.au
DocumentRoot /htdocs/butterflies/
</VirtualHost>

j4mes

4:29 pm on Jul 2, 2005 (gmt 0)

10+ Year Member



Those asterisks (*) are there intentionally - what I wrote should work as-is (i.e. NO changes needed at all).

I looked over your httpd.conf and I think I found the problems - you need to comment out the ServerName on line 213 because it is overriding the VirtualHosts directives, and also the DocumentRoot on line 229 for the same reason.

The *:80 is intentional in what I've written above, pasting it straight in *should* work, providing those directories are correct, and everything conflicting with/overriding it is commented out.

Keep me posted :-)

WiseWombat

10:50 am on Jul 3, 2005 (gmt 0)

10+ Year Member



Hi again I uncommented line 213
And came up with this error in my access logs.

Warning: DocumentRoot [/htdocs/OurShop/] does not exist
Warning: DocumentRoot [/htdocs/butterflies/] does not exist
Apache.exe: Could not determine the server's fully qualified domain name, using XXX.XXX.XXX.XXX for

ServerName
Warning: DocumentRoot [/htdocs/OurShop/] does not exist
Warning: DocumentRoot [/htdocs/butterflies/] does not exist
Apache.exe: Could not determine the server's fully qualified domain name, using XXX.XXX.XXX.XXX for

ServerName.

XXX.XXX.XXX.XXX being my router designated local area network IP Address.

I then reset line 213 TO ServerName 203.56.244.186:80 being my static IP and my configure to.

NameVirtualHost 203.56.244.186
<VirtualHost 203.56.244.186:80>
ServerName www.wisewombat.com.au
DocumentRoot /htdocs/OurShop/
</VIRTUALHOST>
<VIRTUALHOST>
ServerAlias butterflyworld.com.au *.butterflyworld.com.au
DocumentRoot /htdocs/butterflies/
</VirtualHost>.
The server runs and starts but it still doesnt direction the guests to the desired websites directorys.
Any other ideas At least every thing seems to run now.
And thanks for taking the time to have alook for me.

j4mes

11:09 am on Jul 3, 2005 (gmt 0)

10+ Year Member



Warning: DocumentRoot [/htdocs/OurShop/] does not exist
Warning: DocumentRoot [/htdocs/butterflies/] does not exist

You must use an ABSOLUTE directory path, not a relative one.

Use the lines I wrote above in your httpd.conf, the lines you wrote WON'T WORK.

Comment out the lines I suggested, otherwise it will override the settings.

This:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.wisewombat.com.au
ServerAlias *.wisewombat.com.au
DocumentRoot /Program Files/Apache Group/Apache2/htdocs/OurShop/
</VirtualHost>

<VirtualHost *:80>
ServerName www.butterflyworld.com.au
ServerAlias *.butterflyworld.com.au
DocumentRoot /Program Files/Apache Group/Apache2/htdocs/butterflies/
</VirtualHost>

should work.

This:

NameVirtualHost 203.56.244.186
<VirtualHost 203.56.244.186:80>
ServerName www.wisewombat.com.au
DocumentRoot /htdocs/OurShop/
</VIRTUALHOST>
<VIRTUALHOST>
ServerAlias butterflyworld.com.au *.butterflyworld.com.au
DocumentRoot /htdocs/butterflies/
</VirtualHost>

Won't ever work, it's just wrong.