【问题标题】:NGINX Mod_rewrite, Subfolder redirect to folderNGINX Mod_rewrite,子文件夹重定向到文件夹
【发布时间】:2017-03-09 16:43:06
【问题描述】:

我是新手,我对 NGINX 中的 rewrite mod 有疑问。

我给你环境: 我有 2 个应用程序:

  • 每一个 www/
  • 另一个 www/atri/

两个应用程序都需要是 Mod_rewrite,所以我使用这个:

location / {
try_files $uri $uri/ /index.php?$args;
}

这完全适用于第一个应用程序,但是,当我继续第二个应用程序 /atri/ 时,这会加载所有应用程序,就像文件夹 /www/ 中第一个应用程序的相同根目录一样。 你有想法在conf中分离2个应用程序吗?

有关信息,我使用 codeigniter。

感谢您的回复。

【问题讨论】:

    标签: codeigniter mod-rewrite nginx configuration subdirectory


    【解决方案1】:
    location /atri/ {
    alias  /var/www/html/atri/;
    try_files $uri $uri/ /atri/index.php;
    
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index   index.php;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        include /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME $request_filename;
    }
    

    }

    试试这个!

    【讨论】:

      【解决方案2】:

      试试:

      location / {
          try_files $uri $uri/ /index.php?$args;
      }
      location /atri {
          try_files $uri $uri/ /atri/index.php?$args;
      }
      

      请参阅this document 了解更多信息。

      【讨论】:

        猜你喜欢
        • 2014-09-02
        • 2013-03-13
        • 1970-01-01
        • 2017-05-10
        • 1970-01-01
        • 2021-09-08
        • 1970-01-01
        • 2012-12-03
        • 2016-11-11
        相关资源
        最近更新 更多