.htaccess重写url - 来自~username - osx apache

时间:2013-04-22 06:55:26

标签: macos .htaccess mod-rewrite apache2

您好我在mac上使用apache,我启用了php。我正在尝试使用.htacess重写我的网址。

http://localhost/~username/project/test  to http://localhost/~username/project/index.php?url=test
But received 404 error - on retrieving url - http://localhost/~username/project/test .

But - this - http://localhost/~username/project/index.php?url=test - Php is working fine.

我的.htacess文件包含以下五行:


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

我可以在php信息中看到加载模块中的mod_rewrite。我如何调试这个以确定是否正在调用.htaccess。

我的.htaccess文件的路径是 - ~username / Sites / project / .htaccess。

1 个答案:

答案 0 :(得分:0)

来自Troubleshooting

  

确保您没有对相关文件范围生效的AllowOverride无效。对此的一个很好的测试是将垃圾放入.htaccess文件并重新加载页面。如果未生成服务器错误,则几乎肯定会使AllowOverride无效。

或者相反,向htaccess添加一些垃圾,即

Foobar

并重新加载页面。如果您收到一些500服务器错误消息,则启用htaccess(AllowOveride)。