您的位置:首页 > 运维架构 > Nginx

nginx 配置 ThinkPHP Rewrite

2016-03-07 08:49 519 查看
server {
listen       80;
server_name  www.funsion.com;
root /www/web/funsion;
index  index.php;
location / {
# 不带www的时候,自动加上www
if ($host !~ '^www') {
rewrite "^/(.*)$" http://www.$host/$1 permanent;
}

if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}

location ~ .*\.(php|php5)?$ {
fastcgi_pass  127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;

# 自定义服务器环境变量
fastcgi_param DB_TYPE 'mysql';
fastcgi_param DB_HOST '127.0.0.1';
fastcgi_param DB_NAME 'funsion_db';
fastcgi_param DB_USER 'wfc';
fastcgi_param DB_PWD '123456';
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}

location ~ .*\.(js|css)?$ {
expires 1d;
}

location ~ ^(/ThinkPHP|/Application|/Runtime|/Db|/Addons|/.git)/ {
# 防止核心文件被访问
return 404;
}

access_log  /home/log/nginx/access/www.test.com.log;
error_log  /home/log/nginx/www.test.com.error.log;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: