Apache2 mod_rewrite + userdir

我有一个Ubuntu服务器(networking)具有以下configuration

  • 版本:13.10
  • 安装了:Apache2,apache2 utils,php5
  • 启用:重写,userdir

问题

当我尝试使用重写规则,例如foo.bar.com/~«user»/page ,我得到

在此服务器上找不到请求的URL /home/«user»/public_html/page.php

据我所知,它在那里; 当我访问foo.bar.com/~«user»/page.php ; 田田! 它在那里。

我读了/etc/apache2/apache2.conf下的所有configuration,/ /etc/apache2/apache2.conf / /etc/apache2/mods-available/userdir.conf /etc/apache2/apache2.conf ,但对我来说没有什么奇怪的。

附加信息

用户foder权限: drwx rx rx

public_html drwx rx rx权限

我读了我必须提供重写基地,但我真的没有看到什么奇怪的path

我错过了什么?


重写规则:

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

要么

 RewriteRule ^login/? login.php [L] 

顺便说一句,我试图将目录移动到/ var / www和重写规则现在可以运行没有404错误。

你似乎没有一个RewriteBase集,所以它很可能默认为:

 RewriteBase / 

所以,如果你想用它作为userdir或许你应该改变你的Apacheconfiguration文件的重写规则 – 在apache2.confhttpd.conf – 是这样的:

 RewriteEngine on RewriteBase /~username/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php 

我在ubuntuforums.org上find了这个:

RewriteBase /~username/

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