我有一个Ubuntu服务器(networking)具有以下configuration
当我尝试使用重写规则,例如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.conf
或httpd.conf
– 是这样的:
RewriteEngine on RewriteBase /~username/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php
我在ubuntuforums.org上find了这个:
RewriteBase /~username/