科技常识:nginx支持codeigniter的pathinfo模式url重写配置写法示例

2021-03-16 07:05:13
导读 今天小编跟大家讲解下有关nginx支持codeigniter的pathinfo模式url重写配置写法示例 ,相信小伙伴们对这个话题应该也很关注吧,小编也收集

今天小编跟大家讲解下有关nginx支持codeigniter的pathinfo模式url重写配置写法示例 ,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关nginx支持codeigniter的pathinfo模式url重写配置写法示例 的相关资料,希望小伙伴会喜欢也能够帮助大家。

开发环境

codeigniter 2.14PHP 5.4.18nginx 1.4.2

Codeigniter配置

打开 codeignite 的 config.php 文件修改如下:

$config['uri_protocol'] ="PATH_INFO";

nginx配置

打开 nginx 的配置文件 nginx.conf 文件,修改如下:

# 我使用的是虚拟主机配置server { listen 80; server_name dev.example.com; rewrite_log on; root /www/web/htdocs/dev.example.com; index index.php index.html index.htm; location / { index index.php index.html index.htm; } location ~ \.php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } location ~ /\.ht { deny all; }}

现在就可以用pathinfo模式访问了,如:

http://dev.example.com/app/welcome/test

来源:爱蒂网

免责声明:本文由用户上传,如有侵权请联系删除!

猜你喜欢

最新文章