Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't Apache redirect my IP address to the desired location on my server?

Tags:

apache2

I made a simple page /home/david/mainSite/index.html. I then added a virtual host in Apache to redirect my IP address to this page.

<VirtualHost *:80>
ServerName 74.181.105.228
DocumentRoot /home/david/mainSite
</VirtualHost>

However, when I go to 74.181.105.228after restarting Apache, I get a page with this text instead of "index.html."

Welcome to mydomain.com!
This is the default web page for this server.
The web server software is running but no content has been added, yet.

Why does Apache redirect to the default page instead of "/home/david/mainSite/index.html"?

Here is how my "/etc/apache2/sites-available/default" file looks like.

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>
like image 580
dangerChihuahua007 Avatar asked Nov 14 '22 04:11

dangerChihuahua007


1 Answers

I discovered the answer! It was tricky.

In "apache2.conf", I originally had ServerName 74.181.105.228, which makes accessing 74.181.105.228 via a browser load the default page for my server.

Changing this value in "apache2.conf" to ServerName mydomain.com solves the problem since Apache no longer directs 74.181.105.228 to the default page of my server. In turn, I can direct 74.181.105.228 to load a page from a certain directory in my file system.

My virtual host block still remains

<VirtualHost *:80>
ServerName 74.181.105.228
DocumentRoot /home/david/mainSite
</VirtualHost
like image 179
dangerChihuahua007 Avatar answered Dec 06 '22 05:12

dangerChihuahua007