简体   繁体   English

Apache Mod重写不适用于Mac OS X Lion

[英]Apache mod rewrite not working on mac os x lion

I'm trying to set up mod rewrite on os x and it doesn't seem to be working properly. 我正在尝试在os x上设置mod rewrite,它似乎无法正常工作。

I've edited my httpd.conf file to include the module, I've changed the AllowOverride setting to "all" in both my httpd.conf and my user.conf file. 我已经编辑了httpd.conf文件以包括该模块,并且在httpd.conf和user.conf文件中都将AllowOverride设置更改为“ all”。

Now when I add a htaccess file with the following: 现在,当我添加带有以下内容的htaccess文件时:

RewriteEngine on
RewriteRule    ^$ public/        [L]
RewriteRule    (.*) public/$1    [L]

I get a 404 not found saying ... 我得到一个404未找到说...

"The requested URL /Users/matt/Sites/framework/public/ was not found on this server." “在此服务器上找不到请求的URL / Users / matt / Sites / framework / public /。”

Even though that folder does exist. 即使该文件夹确实存在。

The fact that it's redirecting would suggest that mod rewrite is installed and working, but I'm not sure why I'm getting a 404. Any one else had this problem? 重定向的事实表明已安装并运行了mod rewrite,但是我不确定为什么要得到404。还有其他人遇到这个问题吗?

Thanks 谢谢

I did test your rewrite rule on a Windows machine and it thrown Internal server error. 我确实在Windows计算机上测试了您的重写规则,并抛出了内部服务器错误。 I tweaked it a little bit and came to this solution and it seems to work just fine on my test environment. 我进行了一些调整,得出了这个解决方案,它在我的测试环境中似乎还可以正常工作。

Could you give it a try and see if it's ok for you? 您可以尝试一下,看看是否还可以吗?

RewriteEngine on
RewriteRule ^public/ - [L]
RewriteRule .* public/$0 [L] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM