-1

I wanted to set up a virtualhost for my apache2 running on my computer. So when I browse to: "invision.jan.pcsg" I get the page contents/folder structure from "/var/www/html/invision"

This is the virtualhost file "invision.jan.pcsg.conf" I created:

<VirtualHost invision.jan.pcsg:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/invision
    ServerName invision.jan.pcsg 
    ServerAlias hkl.mor.pcsg hkl_at.mor.pcsg


    <Directory />
            Options FollowSymLinks
            AllowOverride FileInfo
    </Directory>
    <Directory /var/www/html/invision/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride all
            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>

When I browse to "invision.jan.pcsg" now, I get redirected to localhost and the "php is working"-page is displayed.

When browsing to "jan.pcsg" the folder contents of "/var/www" is displayed.

Does anyone have an idea why this happens?

1
  • Do you have some rewrites in your .htaccess or you framework or your Script? Jun 3, 2015 at 8:21

1 Answer 1

1

First, you don't need the domain name on the first line. The first line should be: <VirtualHost *:80>. Second, the ServerName and ServerAlias should be the same domain. If you want different domains to point to the same root directory, you need to set up multiple virtual hosts. Please find the instructions here.

Not the answer you're looking for? Browse other questions tagged .