除主页外未找到
我正在使用 YII 框架。我可以通过以下方式访问我的网站:localhost/index.php 然后,如果我单击它上面的任何链接,它会显示:404 未找到。 它适用于阿帕奇。我尝试使用 NGINX 配置它,但没有成功。有人可以告诉我如果某些东西适用于 Apache 但不适用于 NGINX 可能会出现什么问题吗?
来自 nginx 的日志错误:
2011/05/07 11:27:42 [错误] 5104#3152: *30 CreateFile() "c:\EWemp\nginx-0.8.52/html/rooms/finished" 失败 (3:系统找不到指定的路径),客户端:127.0.0.1,服务器:localhost,请求:“GET /rooms/finished HTTP/1.1”,主机:“localhost”,引用者:“http://localhost/index.php”
因此,我认为它需要某种 URL 重写,因为我没有 html/rooms/finished 目录。 它就像 html/controller/action/ 但我不知道要更改什么才能使其正常工作
I'm using YII framework. I can access my site through: localhost/index.php
then If I click any links on it it says: 404 not found.
It works on Apache. I'm trying to configure it with NGINX with no success. Can somebody please tell me what can be the problem if something works with Apache but does not work with NGINX?
Log error from nginx:
2011/05/07 11:27:42 [error] 5104#3152: *30 CreateFile() "c:\EWemp\nginx-0.8.52/html/rooms/finished" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /rooms/finished HTTP/1.1", host: "localhost", referrer: "http://localhost/index.php"
So, I assume that it needs some kind of URL rewrite, since I do not have html/rooms/finished directory.
It is like html/controller/action/ but I do not know what to change in order to get it to work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Yii 使用一个index.php 文件来处理所有客户端请求。您需要将
/rooms/finished
重写为index.php/rooms/finished
。我已使用此 Nginx 配置来重写由一个 index.php 文件处理的所有请求。此配置使用 Fast-CGI 将 PHP 请求传递给 PHP-FPM。如果您使用
proxy_pass
,则可以使用rewrite
。 此处解释了proxy_pass
。Yii uses one index.php file to handle all client requests. You need to rewrite
/rooms/finished
toindex.php/rooms/finished
.I have used this Nginx configuration to rewrite all requests to be handled by one index.php file. This configuration uses Fast-CGI to pass PHP requests to PHP-FPM. If you use
proxy_pass
, you can userewrite
.proxy_pass
is explained here.在我看来,也许你应该像在 Apache 中一样制作“.htaccess 文件”。
In my opinion, may be you should make ".htaccess file" like in Apache.