首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

nginx解决www跟wap的选择访问

2012-12-26 
nginx解决www和wap的选择访问解决手机端访问www网站时切换到wap网页,同时pc机访问wap时切换到www端。1.在wi

nginx解决www和wap的选择访问

解决手机端访问www网站时切换到wap网页,同时pc机访问wap时切换到www端。

1.在windows下第一次使用nginx。实现服务器分担访问。

在 http://wiki.nginx.org/NginxChsInstall 下载nginx0.8.54 windows版本。安装到能找到的地方就行,例如:C:\nginx-0.8.54。配置conf文件下的nginx.conf。这个文件时nginx的配置文件。nginx.conf文件中找到server{},在它的上面加入:?
?

这里推荐使用filefox中的user agent switcher 来模拟各个不通的UA。

这基本就能做到www和wap的选择。不过,这个每次都要进行判断的话,严重影响速度。所以有谁知道该怎么做www和wap跳转的方法就告诉我,谢谢了。

我是新手,望各位大侠指正。

?

?

rewrite "^/sns/create$" /sns.php?do=create last;
rewrite "^/sns/([1-9][0-9]*)$" /sns.php?_id=$1 last;
rewrite "^/news$" /news.php last;
rewrite "^/news/([1-9][0-9]*)$" /news.php?_id=$1 last;
rewrite "^/news/([a-zA-Z][0-9a-zA-Z]*)$" /news.php last;
rewrite "^/book$" /book.php last;
rewrite "^/book/([a-zA-Z]+)$" /book.php?_mod=$1 last;
rewrite "^/comment/([1-9][0-9]*)$" /comment.php?_id=$1 last;
rewrite "^/branch$" /branch.php last;
rewrite "^/branch/([1-9][0-9]*)$" /branch.php?_id=$1 last;
rewrite "^/admin$" /admin/admin.php last;
rewrite "^/admin/([a-z]+)$" /admin/admin.php?_mod=$1 last;
rewrite "^/admin/([a-z]+)/([^/]+)$" /admin/admin.php?_mod=$1&_id=$2 last;
rewrite "^/admin/([a-z]+)/([a-z]+)/([^/]+)$" /admin/admin.php?_mod=$1&_id=$2&_type=$3 last;       

          } 
  
 
        
    location ~ .*\.(php|php5)?$
   {     
     #fastcgi_pass  unix:/tmp/php-cgi.sock;
     fastcgi_pass  127.0.0.1:9000;
     fastcgi_index index.php;
     include fcgi.conf;

   }
  
   
   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
     expires      30d;
   }
   
   location ~ .*\.(js|css)?$
   {
     expires      1h;
   }   
   
   log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';
   access_log  logs/access.log  access;
   }  
    upstream waptodayinns{  
    server wap.todayinns.com;  
       server_name  www.todayinns.com;
   index index.php index.html index.htm;
   root  /var/www/html;  
 
  
     }


   
       
      
       
}

热点排行