Codeigniter 的 NGINX 服务器配置 [英] NGINX server configuration for Codeigniter

查看:79
本文介绍了Codeigniter 的 NGINX 服务器配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

/etc/nginx/conf.d/default.conf

/etc/nginx/conf.d/default.conf

server{
listen 80;
listen [::]:80;
server_name  192.168.56.101 192.168.101.100 localhost;
root   /var/www/html;
index index.php index.html index.htm;

location / {
    try_files $uri $uri/ =404;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;

location = /50x.html {
    root /var/www/html;
}

location ~ \.php$ {
    try_files $uri =404;
    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;
}


location ~ /\.ht {
    deny all;
}
}

<小时>

我的 codeigniter 文件夹是ci",它位于/var/www/html/ci我需要什么配置才能进行 url 重写?...


my codeigniter folder is 'ci' which is located in /var/www/html/ci what configuration do I need to work url rewriting?...

推荐答案

我不想更改当前文档根目录 (/var/www/html)因为我的ci"文件夹位于 /var/www/html/ci.

I didn't want to change the current document root (/var/www/html) since my 'ci' folder is located at /var/www/html/ci.

因此,我在 /etc/nginx/conf.d/default.conf 中创建了一个新的位置块:

So instead, I created a new location block in /etc/nginx/conf.d/default.conf:

server{
...
    location /ci {
        try_files $uri $uri/ /ci/index.php?/$request_uri;
    }
...
}

感谢 Mert Öksüz 建议使用 try_files $uri $uri//ci/index.php?/$request_uri;.

这篇关于Codeigniter 的 NGINX 服务器配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆