CODEIGNITER - Nginx配置可以在子文件夹中读取子文件夹而不是uri吗?

时间:2015-02-26 05:27:48

标签: codeigniter nginx

这是我的配置。

server {
listen 80;
server_name domain.com;

if ($http_x_forwarded_proto = "http") {
    return 301 https://domain.com$request_uri;
}

if (!-e $request_filename){
    rewrite ^/(.*)$ /index.php?/$1 last;
    break;
}

#proxy_cache_path /usr/local/nginx/cache  levels=1:2 keys_zone=STATIC:10m i$
include  mime.types;
default_type application/octet-stream;
gzip  on;


root /var/www/domain.com/html;
index  index.php index.html;

location / {
    rewrite ^(.*)$ /index.php;
}

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

location ~ ^/(images|js|css)/(.*)$ {
    try_files $uri $uri/;
}

location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        root  /images;
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

location ~* \.(eot|ttf|woff)$ {
    add_header Access-Control-Allow-Origin *;
    break;
}

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

}

我试着整整一天。

可以访问domain.com/x/ or domain.com/x/index.php 但无法访问domain.com/x/welcomedomain.com/x/index.php/welcome

FLOW

domain.com = codeigniter framework

domain.com/x = codeigniter framework

主要是我尝试使用try_files也没有成功, 即使我尝试这一个也无法成功 rewrite ^/(.*)$ /index.php?/$1 last;

请参阅location / x

1 个答案:

答案 0 :(得分:0)

只需删除即可使uri成功访问

if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}