3

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.

1
  • 1
    Updated my question
    – erdemkeren
    Nov 12, 2013 at 13:29

2 Answers 2

4

You don’t seem to have a RewriteBase set, so it is most likely defaulting to:

RewriteBase /

So if you want to use it for userdir perhaps you should change your rewrite rules in your Apache config file—in apache2.conf or httpd.conf—to be like this:

RewriteEngine on
RewriteBase /~username/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
4
  • Thanks for your answer. But as I wrote in my question; I don't want to provide this information in .htaccess file. Isn't there any place where I can specify that, so every .htaccess file don't include that line.
    – erdemkeren
    Nov 12, 2013 at 15:13
  • Who said this should be placed in an .htaccess file? Put it in the main Apache2 server config for the whole domain & you are done. Nov 12, 2013 at 15:59
  • I said I don't know where to place it. Thanks.
    – erdemkeren
    Nov 12, 2013 at 17:21
  • Look in /etc/apache2/apache2.conf or /etc/apache2/httpd.conf. Nov 12, 2013 at 17:51
2

I found this on ubuntuforums.org:

RewriteBase /~username/

http://ubuntuforums.org/showthread.php?t=1196217

2
  • Thanks for your answer. But as I wrote in my question; I don't want to provide this information in .htaccess file. Isn't there any place where I can specify that, so every .htaccess file don't include that line.
    – erdemkeren
    Nov 12, 2013 at 15:13
  • So where do you have these rewrite rules? In userdir.conf? Try to add it in there I guess..
    – Alex
    Nov 12, 2013 at 15:42

You must log in to answer this question.

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