Apache httpd.conf <VirtualHost> issue


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Apache httpd.conf <VirtualHost> issue
# 1  
Old 07-01-2003
Apache httpd.conf <VirtualHost> issue

I have just configured httpd.conf on a new Redhat 9 install. Below are my additions to httpd.conf. Everything works fine except that when typing http://spetnik.d2g.com into my web browser, I am sent to the "Default catch all" site. Any clues?

Code:
NameVirtualHost *:80

#Default catch all 
<VirtualHost *:80>
    ServerAdmin aspetner@spetnik.com
    DocumentRoot /var/www/html/
    ErrorDocument 404 /errors/notfound.html
</VirtualHost>

#spetnik.d2g.com
<VirtualHost *:80>
    ServerName spetnik.d2g.com
    ServerAlias spetnik.d2g.com www.spetnik.d2g.com
    ServerAdmin aspetner@spetnik.com
    DocumentRoot /var/www/spetnik/html/
    ErrorDocument 404 /errors/notfound.html
    TransferLog logs/spetnik

    <Directory /var/www/spetnik/html>
        AllowOverride All
    </Directory>
</VirtualHost>

#e-feedback.org
<VirtualHost *:80>
    ServerName e-feedback.org
    ServerAlias e-feedback.org www.e-feedback.org
    ServerAdmin e-feedback@spetnik.com
    DocumentRoot /var/www/e-feedback/html
    ErrorDocument 404 /errors/notfound.html
    TransferLog logs/e-feedback

    <Directory /var/www/e-feedback/html>
        AllowOverride All
    </Directory>
</VirtualHost>

Thanks,
Aaron
# 2  
Old 07-01-2003
I assume that's your website then... you need to create the webpage you want users to see when they visit your website - create a basic html file and name it "index.html" and place it in the main directory of your site, probably /var/www/html/.
# 3  
Old 07-01-2003
I don't think you understand. Both e-feedback.org and www.e-feedback.org display the index.html file from /var/www/e-feedback/html. www.spetnik.d2g.com also displays /var/www/spetnik/html/index.html, but if I take out the www (just spetnik.d2g.com), I get the catch all directory (/var/www/html).
# 4  
Old 07-01-2003
Now I see what you're saying..

Looking at the documentation, I can't figure out what's wrong, but I'm sure someone else will know.
# 5  
Old 07-01-2003
In your first virtual host, you specify your domain as spetnik.d2g.com. I don't have a way to test this, but to my way of thinking, this would be a host.domain.com. (Your other one works because it is has only a domain - e-feedback.org )

<VirtualHost *:80>
ServerName spetnik.d2g.com
ServerAlias spetnik.d2g.com www.spetnik.d2g.com
ServerAdmin aspetner@spetnik.com
DocumentRoot /var/www/spetnik/html/

Part of the documentation states:
Quote:
Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example if you add this to the first <VirtualHost> block above

ServerAlias domain.tld *.domain.tld
then requests for all hosts in the domain.tld domain will be served by the www.domain.tld virtual host.
Since you probably can't change servername to d2g.com, try the following instead (found in the FAQ section of Apache's documentation):
Quote:
There are two techniques to implement canonical hostnames:

Use mod_rewrite as described in the "Canonical Hostnames" section of the URL Rewriting Guide.
Use name-based virtual hosting:
NameVirtualHost *

<VirtualHost *>
ServerName www.example.net
ServerAlias example.com
Redirect permanent / http://www.example.com/
</VirtualHost>

<VirtualHost *>
ServerName www.example.com
DocumentRoot /usr/local/apache/htdocs
</VirtualHost>
Worth a shot, anyway.
# 6  
Old 07-01-2003
Nevermind, I figured it out. I had "ServerName spetnik.d2g.com:80" set at the top of my httpd.conf file. I changed it to "ServerName linuxsrv:80" (linuxsrv is the machine name) and it now works fine.

Thanx for the help anyway Smilie.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and comment block of text from apache httpd.conf

I want to search for a block of text in httpd.conf that between two strings and comment it. There are multiple blocks with "<Directory.. and </Directory>" <Directory "${ORACLE_INSTANCE}/config/${COMPONENT_TYPE}/${COMPONENT_NAME}/htdocs"> # # Possible values for the Options directive are... (3 Replies)
Discussion started by: kchinnam
3 Replies

2. Linux

Apache/2.2.25 VirtualHost not working

I am having problems in implementing the virtual hosts here in my server. I have this one cloud dev server: Amazon Linux AMI release 2013.03 (based on RHEL like CentOS) with Apache 2.2.25 installed and I'm trying to create 2 virtual hosts: test-kalc.tk and test2-kalc.tk. If I go to... (2 Replies)
Discussion started by: jpdoria
2 Replies

3. Red Hat

apache httpd virtual hosts setup keep hitting the same VirtualHost

I'm trying to set up two virtual hosts. Here's my httpd config: <Directory /Users/userX/dev/sandbox-2> Order deny,allow deny from All Allow from localhost </Directory> NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> DocumentRoot "/Users/userX/dev/sandbox-2" ... (0 Replies)
Discussion started by: GlideK
0 Replies

4. UNIX for Dummies Questions & Answers

Locate which httpd.conf is used by Apache

What is the command to see what httpd.conf file is apache using. Apache is started. (1 Reply)
Discussion started by: galford
1 Replies

5. Red Hat

apache 2.2 httpd.conf

Hi, I was wondering if someone could help me out here. I am super-paranoid, so am trying to limit what PHP files can be executed on this server. I have a small list of files that I want to allow. The rest, deny: <Files ~ "\.(php|php3)$"> order allow,deny deny from all </Files> I... (0 Replies)
Discussion started by: Lobster
0 Replies

6. Red Hat

apache 2.2 httpd.conf

Hi, I was wondering if someone could help me out here. I am super-paranoid, so am trying to limit what PHP files can be executed on this server. I have a small list of files that I want to allow. The rest, deny. So I have base rule that denies all php files server-wide: order allow,deny ... (0 Replies)
Discussion started by: Lobster
0 Replies

7. Web Development

servername in apache httpd.conf

I'd like to know if servername in apache httpd.conf is the machine name or domain name. If it is domain name like example.com, should it be registered before in use? (1 Reply)
Discussion started by: yzhang738
1 Replies

8. Web Development

Apache virtualhost dinternal domain

Hello, I have have installed two web applications on one server with one IP address and one domain name (mynet.intra). Is it possible to configure in apache 2.2 that access to one application would be from "app1.mynet.intra" and to another application from address "app2.mynet.intra"? Document... (1 Reply)
Discussion started by: kreno
1 Replies

9. Web Development

Apache: Forward Proxy Via Virtualhost

I've set up a forward proxy within a VirtualHost (see below) on Apache 2.2.11. I then browse using mydomain.com:80 as the proxy - I've also tried using the IP address of the VirtualHost xxx.xxx.xxx.xxx:80. It works fine, the only problem is that in both cases the server's main IP address is always... (2 Replies)
Discussion started by: krunksta
2 Replies

10. Ubuntu

Apache 2 httpd.conf empty

Hi everybody, I have installed Apache 2 + Tomcat 5.5. on Ubuntu 7.04 and the default httpd.conf is empty (0 lines), however there is a file called apache2.conf that looks like a default httpd.conf. I didn't use Apache in ages, since 1.3.x release, but I remember that the httpd.conf by default... (2 Replies)
Discussion started by: sspirito
2 Replies
Login or Register to Ask a Question