这是我的配置。
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/welcome
或domain.com/x/index.php/welcome
domain.com = codeigniter framework
domain.com/x = codeigniter framework
主要是我尝试使用try_files
也没有成功,
即使我尝试这一个也无法成功
rewrite ^/(.*)$ /index.php?/$1 last;
请参阅location / x
答案 0 :(得分:0)
只需删除即可使uri成功访问
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}