Using <VirtualHost> over .htaccess for mod_rewrite

Posted by DarkWolffe on Server Fault See other posts from Server Fault or by DarkWolffe
Published on 2012-11-25T00:09:44Z Indexed on 2012/11/25 23:08 UTC
Read the original article Hit count: 258

Filed under:
|
|
|
|

I have a LAMP stack installed on Ubuntu 12.10 with three sites created under /etc/apache2/sites-available, all of which are working. My problem lies in wanting to use those files over .htaccess for appending the .php file extension from the URL. My file currently stands as such:

# The VGC
<VirtualHost *:80>
            ServerAdmin [email protected]
            ServerName thevgc.net
            ServerAlias www.thevgc.net

            DocumentRoot /var/www/www
            <Directory />
                    Options FollowSymLinks
                    AllowOverride All
            </Directory>
        <Directory /var/www/www/>
                Options Indexes +FollowSymLinks +MultiViews Includes
                RewriteEngine On
                RewriteBase /
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ $1.php [L,QSA]
                AddType application/x-httpd-php .php
                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
    </VirtualHost>

I'm almost certain I'm doing something wrong. All I know is that my .htaccess files refused to append the extension, or rather find the file that has the same name and load that file, so I wanted to go about this method.

Any suggestions? Here is an example page from my site.

© Server Fault or respective owner

Related posts about php

Related posts about apache2