ikscher
2015-12-24 05:32nginx配置thinkphp的rewrite
以前web用apache的架设thinkphp的程序,但是转为nginx的服务器后,一直不能
正常网站,就是规则重写的问题;
apache的配置:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
RewriteRule ^/?([a-zA-Z0-9]+)$ index.php?app=home&mod=Public&act=error404 [L]
在Nginx的配置是这样的:
location / {
root /wwwroot/mysite;
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~* .php$ {
root /wwwroot/mysite;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$"){
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
看了网上很多有关解决的方案,都不生效,我的Nginx的版本1.4的;如有解答,不胜感激!!!
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- nginx 配置fastcgi,解析php的问题
- nginx
- 3个回答
- nginx配置问题--如何让图片显示出来
- django
- nginx
- 1个回答
- 使用Slim Framework进行Nginx配置,如何保留.php网址
- configuration
- slim
- php
- nginx
- 2个回答
- nginx配置同一应用三个tomcat,都能登录,但是访问不了其他页面,但是关闭两个后,页面就能访问
- 负载均衡
- 缓存
- nginx
- 2个回答
- nginx配置问题,谢谢帮忙
- linux
- macos
- tomcat
- centos
- 3个回答