Ubuntu – MultiViews not working on Ubuntu

apache-2.4Ubuntu

I've been banging my head for hours and I can't seem to get this to work. Please help. I'm trying to make apache open php files without extensions. This is my apache2.conf:

Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride Indexes
    Allow from All
    Require all granted
</Directory>

<Directory /var/www/subdomain.example.com/public_html   >
    Options +MultiViews
</Directory>

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

IncludeOptional sites-enabled/*.conf

And I've got these two config files in sites-enabled (disabled 000-default.conf).. here is the first one, lets call it example.com.conf:

<VirtualHost *:80>

    ServerName example.com
    ServerAlias www.example.com

    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/example.com/public_html

    ErrorLog ${APACHE_LOG_DIR}/example.com.error.log
    CustomLog ${APACHE_LOG_DIR}/exmple.com.access.log combined

</VirtualHost>

and for the second one subdomain.example.com.conf:

<VirtualHost *:80>

    ServerName subdomain.example.com

    ServerAdmin webmaster@example.com
    DocumentRoot /var/www/subdomain.example.com/public_html

    <Directory /var/www/subdomain.example.com/public_html >

        allow from all
        AllowOverride All
        Options FollowSymLinks 
        Options +MultiViews

        # RewriteCond %{REQUEST_FILENAME} !-d 
        # RewriteCond %{REQUEST_FILENAME}\.php -f 
        # RewriteRule ^(.*)$ $1.php

    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/subdomain.example.com.error.log
    CustomLog ${APACHE_LOG_DIR}/subdomain.example.com.access.log combined

</VirtualHost>

With this:

  • example.com/index – works (tho it's an html file)
  • subdomain.example.com – works (i get served my index.php)
  • subdomian.example.com/index.php – works (i get served my index.php file)
  • subdomian.example.com/index – DOES NOT WORK

So I'm guessing it's a problem with my apache's config files. . . pleeeeease help. What am I doing wrong?

Best Answer

Do you need 'MultiviewsMatch Any'? This is because the file extension isn't really a mimetype mapping in the way txt/html/etc are.

Related Topic