0

我在根文件夹上使用 xenforo 论坛我使用 Codeigniter 框架添加文件夹/ somefolder /我应该如何编辑我的 nginx coinfig?

server {
    listen       80;
    server_name  wwww.mysite.com mysite.com;
    access_log  /var/log/nginx/mysite_access.log;
error_log  /var/log/nginx/mysite_error.log;

location / {
        root   /usr/local/www/mysite;
        index  index.html index.htm index.php;
        try_files $uri $uri/ /index.php?$uri&$args;
        }    
    location /internal_data/ {
    internal;
    }
    location /library/ {
    internal;
    }           

    location ~ \.php$ {
    fastcgi_pass unix:/var/tmp/fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param  SCRIPT_FILENAME  /usr/local/www/mysite$fastcgi_script_name;
        include        fastcgi_params;
    }
4

1 回答 1

0

检查以下配置。假定/usr/local/www/mysite/为根文件夹。

server {
    listen 80;
    server_name wwww.mysite.com mysite.com;
    access_log /var/log/nginx/mysite_access.log;
    error_log /var/log/nginx/mysite_error.log;

    location /internal_data/ {
        internal;
    }
    location /library/ {
        internal;
    }

    location /somefolder {
        root /usr/local/www/mysite/somefolder;
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /somefolder/index.php?/$1 last;
            break;
        }
    }

    location / {
        fastcgi_pass unix:/var/tmp/fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME  /usr/local/www/mysite$fastcgi_script_name;
        include fastcgi_params;
    }
}

希望这可以帮助。

于 2013-03-07T20:41:40.147 回答