nginx 配置 ThinkPHP Rewrite
Posted Funsion Wu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nginx 配置 ThinkPHP Rewrite相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
Nginx下支持ThinkPHP的Pathinfo和URl Rewrite模式
ThinkPHP3.2.3 Nginx 下 URL_MODEL 的配置
nginx 配置thinkphp 隐藏index.php 并支持pathinfo