view raw
PlayinCOD3142 PlayinCOD3142 - 1 year ago 86
PHP Question

mod_rewrite not working on Ubuntu with apache2

I can't seem to have mod_rewrite working, but it shows it's enabled when I do the phpinfo()
My default file looks like:

ServerAdmin webmaster@localhost

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

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

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

I get the 404 error every time I try to access:

Instead of:

Any idea what's going on?

This is my current

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]


You're missing -MultiViews, with it enable it will not ignore the directory that does not exist.

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

## To internally redirect /anything to /anything.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^(.+?)/?$ $1.php [L]