I have an Ubuntu Server (web) with the following configuration
- Version: 13.10
- Installed: Apache2, apache2 utils, php5
- Enabled: rewrite, userdir
Problem
When I try to use rewrite rules, for example foo.bar.com/~«user»/page
, I get
The requested URL
/home/«user»/public_html/page.php
was not found on this server.
As far as I know it is there; when I visit foo.bar.com/~«user»/page.php
; tada! it is there.
I read all my configurations under /etc/apache2/apache2.conf
, /etc/apache2/mods-available/userdir.conf
but nothing seemed strange to me.
Additional Information
Permissions for user foder: drwx r-x r-x
Permissions for public_html drwx r-x r-x
I read I have to provide rewrite base but I really don't see anything strange with the path
What do I miss?
Rewrite Rules:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Or
RewriteRule ^login/? login.php [L]
By the way, I tried to move the directory to /var/www and rewrite rules are operational now without 404 errors.
Best Answer
You don’t seem to have a
RewriteBase
set, so it is most likely defaulting to:So if you want to use it for
userdir
perhaps you should change your rewrite rules in your Apache config file—inapache2.conf
orhttpd.conf
—to be like this: