码迷,mamicode.com
首页 > 其他好文 > 详细

nginx 重写规则!

时间:2014-12-09 10:39:35      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:nginx

#访问$uri
#if exists $uri -> 访问他
#if $uri is not end of / and exists /Vhosts/$http_host/$uri ->访问他
#if $uri is end of / and exists /Cache/$http_host/$uri/index.html -> 访问他
#否则 $uri -> /index.php 
#结束(by default.fu@foxmail.com -如有错误请联系)


server {
   listen       80;
   server_name  game1.wap.loc game2.wap.loc game3.wap.loc wap.loc www.wap.loc;
   
   location / {
      root   d:/dev_wap;
      index  index.html index.htm index.php;       
      try_files $uri /Vhosts/$http_host/$uri /Cache/$http_host/$uri/index.html @rewrite;    
      
      location ~ \.php$ {
         try_files $uri =404;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include        fastcgi_params;    
      }
   }
   
   location @rewrite {
      rewrite [^\/]$ $uri/ redirect;
      rewrite . /index.php?s=$uri&$args last;
   }
   

   #error_page  404              /404.html;

   # redirect server error pages to the static page /50x.html
   #
   
   error_page   500 502 503 504  /50x.html;
   location = /50x.html {
      root   html;
   }
   
   location ~ /\.(ht|svn|git) {
      deny all;
   }
}

nginx 重写规则!

标签:nginx

原文地址:http://blog.csdn.net/default7/article/details/41819933

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!