Skip to content
wzxjohn edited this page Jan 23, 2015 · 5 revisions

由于 Nginx 不支持 .htaccess 文件,所以如果你想使用 Nginx 的话需要进行额外的配置。

目前有两个方法让程序可以运行在 Nginx 环境下:(理论可行,没有测试

  • 方法一(推荐): 在 Nginx 的配置文件中添加如下代码来代替 .htaccess

      location / {
        rewrite ^/(welcome(/index)?|index(\.php)?)/?$ / redirect;
        rewrite ^/(.*)/index/?$ /$1 redirect;
        if (!-e $request_filename){
          rewrite ^/(.+)/$ /$1 redirect;
        }
        rewrite ^system.* /index.php/$1 break;
        if (!-e $request_filename){
          rewrite ^(.*)$ /index.php/$1 break;
        }
      }
    

本段代码使用 http://winginx.com/en/htaccess 转换而来,没有经过测试。

  • 方法二: 在 application/config/config.php 中查找:

    $config['index_page'] = '';

    将其修改为:

    $config['index_page'] = 'index.php';

    本方法通用性强,但是带来的弊端是所有的链接中都会多出index.php,如 https://ss.qaq.moe/index.php/user.html

Clone this wiki locally