codeigniter nginx rewrite规则配置转
Posted Yuan.Net
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeigniter nginx rewrite规则配置转相关的知识,希望对你有一定的参考价值。
转自:http://www.nginx.cn/1134.html
nginx如何配置才能支持codeigniter ?
1. codeigniter的url美化去掉index.php
1
2
3
4
5
|
2.与thinkphp一样codeigniter的url rewrite也是使用pathinfo来实现的,需要借助fastcgi_split_path_info来设置$_SERVER[‘PATHINFO‘]。
1
2
3
4
5
6
7
8
9
10
|
location ~ ^.+.php {
include fastcgi_params;
root html/gxtp;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
|
codeigniter完整版nginx.conf规则
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.264.cn;
location / {
root html/kdw;
index index.php;
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ ^.+.php {
include fastcgi_params;
root html/kdw;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
}
}
|
以上是关于codeigniter nginx rewrite规则配置转的主要内容,如果未能解决你的问题,请参考以下文章
CodeIgniter:Xampp 上的 Mod_Rewrite
CodeIgniter 删除 index.php apache mod_rewrite
500 内部服务器错误 CodeIgniter htaccess mod_rewrite