首页 > Web开发 > 详细

nginx 配置 ThinkPHP Rewrite

时间:2016-03-07 10:07:01      阅读:232      评论:0      收藏:0      [点我收藏+]
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;

}            

 

nginx 配置 ThinkPHP Rewrite

原文:http://www.cnblogs.com/funsion/p/5249363.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!