同一 tld 下多个 codeignitor 站点的 Nginx 配置

同一 tld 下多个 codeignitor 站点的 Nginx 配置

我有一个网站nginx.asdf.com:8082,其中包含使用 PHP(CodeIgnitor 框架)构建的 CMS。我还有一个在 下运行的类似网站nginx.asdf.com:8082/ghjkl/。我的 Nginx 配置适用于nginx.asdf.com:8082但不适用于nginx.asdf.com:8082/ghjkl/。我当前的 Nginx 配置是:

server {
    listen 8082 default_server;
    listen [::]:8082 default_server;
    server_name nginx.asdf.com;

    root /var/www/nginx.asdf.com/ghjkl/;

    index index.html index.php index.htm;

    # if your default controller is something other than "welcome" you should change the following
    if ($request_uri ~* ^(/pages/views(/index)?|/index(.php)?)/?$)
    {
        rewrite ^(.*)$ / permanent;
    }

    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # removes access to "system" folder, also allows a "System.php" controller
    if ($request_uri ~* ^/system)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }

    # catch all
    error_page 404 /index.php;


    location ~ \.php$ {
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            include snippets/fastcgi-php.conf;
    }

    # deny access to apache .htaccess files
    location ~ /\.ht
    {
        deny all;
    }

}

我应该怎么办?

相关内容