CI框架在NGINX下的伪静态规则修改:
1、location
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
或
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
2、location ~ [^/]\.php(/|$)
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
#增加以下两行
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi.conf;
}
Apache配置方法:
1、修改httpd.conf,开启rewrite模块
LoadModule rewrite_module modules/mod_rewrite.so
2、将站点配置文件中
AllowOverride None 修改为 AllowOverride All
3、在站点根目录添加.htaccess文件,内容如下:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|public|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]