0

对于我的 codeigniter 应用程序中的所有页面,除了我的默认控制器,main.php当我刷新浏览器时,url 不会像预期的那样受到影响。

但是,当我在“http://localhost/main”刷新浏览器时,该main部分会从 url 中删除。所以浏览器栏只显示“http://localhost”。

完全不知道从哪里开始,但只是想知道是否有人以前遇到过这个......?

这就是我认为可能是我的 nginx.conf 的相关部分(如果 Nginx 是问题)。

if ($request_uri ~* ^(/main(/index)?|/index(.php)?)/?$)
{
    rewrite ^(.*)$ / permanent;  
}

请注意,将括号中的代码更改为:

rewrite ^(.*)$ /main permanent; 

导致错误消息The webpage at http://localhost/main has resulted in too many redirects.

4

2 回答 2

0

好的,我回答了我自己的问题。只需注释掉我显示的 nginx.conf 代码即可解决问题。

所以就这样做(Bo Jackson 说):

#if ($request_uri ~* ^(/main(/index)?|/index(.php)?)/?$)
#{
#  rewrite ^(.*)$ / permanent;  
#}
于 2012-12-17T23:10:50.063 回答
0

如果您尝试将您的请求路由到 index.php 引导程序,以便您可以从 CodeIgniter 中的 url 中删除 index.php,您可能应该尝试使用这个:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
于 2012-12-17T23:17:25.713 回答