Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-30-2005, 04:24 AM
|
#1
|
Member
Registered: Sep 2004
Location: India
Distribution: Solaris 9, FreeBSD 4.10, Slackware, RedHat, Knoppix,
Posts: 84
Rep:
|
Apache VirtualHost Redirect Problem...
Hi,
I have set up Apache for the LAN. Every thing is working fine...except that when an 404 error occurs for the first virtual host, apache redirects it to the home page of the first virtual host. However for other virtual hosts, it does not happen like that and works perfectly the way it shud work (giving a Not Found 404 error message).
<VirtualHost 192.168.1.21>
ServerAdmin whatever@whatever.net
DocumentRoot /home/john
ServerName TestServer
ScriptAlias /cgi-bin/ /home/john/cgi-bin/
ErrorLog logs/error.log
TransferLog logs/john.log
</VirtualHost>
<VirtualHost 192.168.1.22>
ServerAdmin whatever@whatever.net
DocumentRoot /home/johnnie
ServerName TestServer
ScriptAlias /cgi-bin/ /home/johnnie/cgi-bin/
ErrorLog logs/error.log
TransferLog logs/johnnie.log
</VirtualHost>
...
So whenever i type something like http://192.168.1.21/doesnotexist.html - it redirects me to the home page for 192.168.1.21
Also the Document Root is set to /home ( incase that helps ) and i m running 1.3.x under FreeBSD 4.10...
Thanks for the reply in Advance,
SiLiCoN
|
|
|
04-30-2005, 09:11 PM
|
#2
|
LQ Guru
Registered: Jan 2001
Posts: 24,149
|
Are both these virtual hosts on the same machine where you have two IP's with two NIC's in place? If your wanting to redirect to another machine behind your firewall using only one public IP address so it redirects to the other virtual host hosted on the second machine, you have to do something like this:
Code:
<VirtualHost *:80>
ServerName virtualname.domain.com
RewriteEngine On
RewriteRule ^(.*)$ http://192.168.1.22$1 [P]
</VirtualHost>
And you can't have two virtual hosts with the same ServerName.. that's probably one reason the second one keeps going back to the first.. etc.
|
|
|
04-30-2005, 09:55 PM
|
#3
|
LQ Newbie
Registered: Apr 2005
Location: FL
Distribution: Fedora Core 10
Posts: 25
Rep:
|
Similar Problem
I have a similar problem.
I have setup 2 virtual hosts, looks something like this:
<VirtualHost myIP:80>
DocumentRoot /var/www/html
ServerAdmin myemail@server.com
ServerName mydomain.com
ServerAlias www.mydomain.com
DirectoryIndex index.php index.html index.htm index.shtml
<Directory "/var/www/html">
AllowOverride all
</Directory>
LogLevel debug
HostNameLookups off
</VirtualHost>
# Virtual host development
<VirtualHost myIP:80>
DocumentRoot /var/www/develop/
ServerAdmin mymail@mail.com
ServerName develop.mydomain.com
<Directory "/var/www/develop/">
AllowOverride all
</Directory>
LogLevel debug
HostNameLookups off
</VirtualHost>
___________________________
When I go to develop.mydomain.com, I get the index page of my first VHost at the /var/www/html directory, as opposed to the /var/www/develop directory.
I have only one IP, but it should make no difference how many IPs I have as long as Apache is set to look for the URL.
|
|
|
05-02-2005, 01:10 AM
|
#4
|
Member
Registered: Sep 2004
Location: India
Distribution: Solaris 9, FreeBSD 4.10, Slackware, RedHat, Knoppix,
Posts: 84
Original Poster
Rep:
|
hi trickykid,
Thanks for the reply...I have just one NIC (aliased from 192.168.1.21- 192.168.1.25). Virtual hosts from 192.168.1.22 - 192.168.1.25 are working fine...just that the first virtual host (which is also the actual ip of the NIC) i'e' 192.168.1.21 does not give me a NOT found (404 error) instead it redirects me to the home page of 192.168.1.21....And yes all of the 5 virtual hosts are in the same machine.
Regards,
SiLiCoN
Last edited by SiLiCoN; 05-02-2005 at 01:11 AM.
|
|
|
05-02-2005, 03:08 AM
|
#5
|
Member
Registered: Sep 2004
Location: India
Distribution: Solaris 9, FreeBSD 4.10, Slackware, RedHat, Knoppix,
Posts: 84
Original Poster
Rep:
|
Code:
When I go to develop.mydomain.com, I get the index page of my first VHost at the /var/www/html directory, as opposed to the /var/www/develop directory.
I have only one IP, but it should make no difference how many IPs I have as long as Apache is set to look for the URL.
Hi ApachePadowan,
Is the DNS working fine, try doing a dig or nslookup on www.mydomain.com and develop.mydomain.com and see if they point to the place u r trying to point. (which i guess is working fine otherwise it would have given a not found message).
Since its a NameVirtual host, put a NameVirtualHost <YOUR_IP> statement just before the two virtual host statement and i guess things will work out fine.
What i mean is - your virtual host declaration should be
NameVirtualHost YOUR_IP
<VirtualHost YOUR_IP>
...
</VirtualHost>
<VirtualHost YOUR_IP>
...
</VirtualHost>
Regards,
SiLiCoN
|
|
|
05-03-2005, 09:41 AM
|
#6
|
LQ Newbie
Registered: Apr 2005
Location: FL
Distribution: Fedora Core 10
Posts: 25
Rep:
|
Thanks, SiLiCon... What I actually did to get it to work was as simple as replacing my IP with a *... Working just fine now...
|
|
|
All times are GMT -5. The time now is 04:21 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|