专注于高品质PHP技术等信息服务于一体 [STIEMAP] [RSS]

百度提供的广告:
Linux
当前位置:首页 > 技术文档 > Linux >  > 
nginx泛域名配置重写
server {
        listen       80;
        server_name  *.qingruxu.com;
        index index.html index.htm index.php;
        root /home/www/qingruxu;

        #@right by : qingruxu date: 2015-07-03 15:58
        location /{

               if ($host ~* "news.qingruxu.com")
               {
                    rewrite ^/$ /index.php/news last;
                    rewrite ^/(\d+)$ /index.php/news/$1 last;
                    break;
               }
               rewrite ^/([\w]+)$ /index.php/$1 last;
        }

$host 是 nginx 提供的表示当前访问的主机是哪个
~* 不区分大小写匹配

当访问的是 news.qingruxu.com 的时候,重写使用 /index.php/news 来显示内容。