亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

nginx怎么配置偽靜態和適配客戶端

發布時間:2022-05-21 10:45:46 來源:億速云 閱讀:177 作者:iii 欄目:大數據

這篇文章主要介紹了nginx怎么配置偽靜態和適配客戶端的相關知識,內容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇nginx怎么配置偽靜態和適配客戶端文章都會有所收獲,下面我們一起來看看吧。

后端用的thinkphp3.2.3框架,如果您是其他的語言或者,注意適當修改下

server {
    listen    80;
    server_name www.morgen.club;

    #charset koi8-r;
    
    #access_log logs/host.access.log main;

網站根目錄

location / {
      root  html;
      index index.html index.htm;
      #設置訪問設備
      set $source_device 'index';
      #判斷為手機客戶端或ipad
      if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
        set $source_device 'phone';
      }
      #根目錄
      if ($request_uri ~* ^/$){
        rewrite ^(.*)$ /index.php?s=/home/$source_device/index.html last;
        break;
      }
      #電腦首頁
      if ($request_uri ~* ^/home/index/index.html$) {
        rewrite ^/home/index/index.html$ /web/ permanent;
        break;
      }
      #電腦首頁分頁
      if ($request_uri ~* ^/home/index/index/page/(\d*).html$) {
        rewrite ^/home/index/index/page/(\d*).html$ /web/pages/$1/ permanent;
        break;
      }
      #電腦首頁分類首頁
      if ($request_uri ~* ^/home/index/index/cate/(\d*).html$) {
        rewrite ^/home/index/index/cate/(\d*).html$ /web/cates/$1/ permanent;
        break;
      }
      #電腦首頁分類分頁
      if ($request_uri ~* ^/home/index/index/cate/(\d*)/page/(\d*).html$) {
        rewrite ^/home/index/index/cate/(\d*)/page/(\d*).html$ /web/cates/$1/pages/$2/ permanent;
        break;
      }
      #電腦首頁搜索
      if ($request_uri ~* ^/home/index/index.html(.*)) {
        rewrite ^/home/index/index.html(.*) /web/search?$query_string permanent;
        break;
      }
      #電腦書籍頁面
      if ($request_uri ~* ^/home/index/books/book/(\d*).html$) {
        rewrite ^/home/index/books/book/(\d*).html$ /web/books/$1/ permanent;
        break;
      }
      #電腦章節頁面
      if ($request_uri ~* ^/home/index/contents/books/(\d*)/chapters/(\d*).html$) {
        rewrite ^/home/index/contents/books/(\d*)/chapters/(\d*).html$ /web/books/$1/chapters/$2/ permanent;
        break;
      }
      #手機首頁
      if ($request_uri ~* ^/home/phone/index.html$) {
        rewrite ^/home/phone/index.html$ /phone/ last;
        break;
      }
      #手機首頁分頁
      if ($request_uri ~* ^/home/phone/index/page/(\d*)(.*)$) {
        rewrite ^/home/phone/index/page/(\d*).html /phone/pages/$1/ permanent;
        break;
      }
      #手機首頁分類首頁
      if ($request_uri ~* ^/home/phone/index/cate/(\d*).html$) {
        rewrite ^/home/phone/index/cate/(\d*).html$ /phone/cates/$1/ permanent;
        break;
      }
      #手機首頁分類分頁
      if ($request_uri ~* ^/home/phone/index/cate/(\d*)/page/(\d*).html$) {
        rewrite ^/home/phone/index/cate/(\d*)/page/(\d*).html$ /phone/cates/$1/pages/$2/ permanent;
        break;
      }
      #手機首頁搜索
      if ($request_uri ~* ^/home/phone/index.html?(.*)) {
        rewrite ^/home/phone/index.html(.*) /phone/index.html$1 permanent;
        break;
      }
      #手機書籍頁面
      if ($request_uri ~* ^/home/phone/books/book/(\d*).html$) {
        rewrite ^/home/phone/books/book/(\d*).html$ /phone/books/$1/ permanent;
        break;
      }
      #手機章節頁面
      if ($request_uri ~* ^/home/phone/contents/books/(\d*)/chapters/(\d*).html$) {
        rewrite ^/home/phone/contents/books/(\d*)/chapters/(\d*).html$ /phone/books/$1/chapters/$2/ permanent;
        break;
      }
      
      if ($request_uri ~* ^/home/book/(.*)$) {
        rewrite ^(.*)$ /index.php?s=$1 last;
        break;
      }

      if (!-e $request_filename) {
        return 404;
      }
    }

電腦瀏覽器端

location /web {
      root html;
      index index.html index.htm;
      #如果設備為手機或ipad
      if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
        rewrite ^/web(.*) /phone$1 permanent;
      }
        #電腦首頁搜索
        if ($request_uri ~ ^/web/search(.*)$) {
          rewrite ^(.*) /index.php?s=/home/index/index.html last;
          break;
        }
        #電腦首頁
        set $index false;
        if ($request_uri ~* ^/web$) {
          set $index true;
        }
        if ($request_uri ~* ^/web/$) {
          set $index true;
        }
        if ($index = true){
          rewrite ^/web(.*) /index.php?s=/home/index/index.html last;
          break;
        }
        #電腦首頁分頁
        set $index_page false;
        if ($request_uri ~* ^/web/pages/(\d*)$) {
          set $index_page true;
        }
        if ($request_uri ~* ^/web/pages/(\d*)/$) {
          set $index_page true;
        }
        if ($index_page = true){
          rewrite ^/web/pages/(\d*)(.*) /index.php?s=/home/index/index/page/$1.html last;
          break;
        }
        #電腦分類首頁
        set $cate false;
        if ($request_uri ~* ^/web/cates/(\d*)$) {
          set $cate true;
        }
        if ($request_uri ~* ^/web/cates/(\d*)/$) {
          set $cate true;
        }
        if ($cate = true){
          rewrite ^/web/cates/(\d*)(.*) /index.php?s=/home/index/index/cate/$1.html last;
          break;
        }
        #電腦分類分頁
        set $cate_page false;
        if ($request_uri ~* ^/web/cates/(\d*)/pages/(\d*)$) {
          set $cate_page true;
        }
        if ($request_uri ~* ^/web/cates/(\d*)/pages/(\d*)/$) {
          set $cate_page true;
        }
        if ($cate_page = true){
          rewrite ^/web/cates/(\d*)/pages/(\d*)(.*) /index.php?s=/home/index/index/cate/$1/page/$2.html last;
          break;
        }
        
        #電腦書籍頁面
        set $book false;
        if ($request_uri ~* ^/web/books/(\d*)$) {
          set $book true;
        }
        if ($request_uri ~* ^/web/books/(\d*)/$) {
          set $book true;
        }
        if ($book = true){
          rewrite ^/web/books/(\d*)(.*) /index.php?s=/home/index/books/book/$1.html last;
          break;
        }
        #電腦章節頁面
        set $chapter false;
        if ($request_uri ~* ^/web/books/(\d*)/chapters/(.*)$) {
          set $chapter true;
        }
        if ($request_uri ~* ^/web/books/(\d*)/chapters/(.*)/$) {
          set $chapter true;
        }
        if ($chapter = true){
          rewrite ^/web/books/(\d*)/chapters/(.*)/ /index.php?s=/home/index/contents/books/$1/chapters/$2.html last;
          break;
        }

        if (!-e $request_filename) {
          return 404;
        }
    }

手機和平板端

location /phone {
      root html;
      index index.html index.htm;
      #如果設備不是手機或ipad
      if ($http_user_agent !~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
        rewrite ^/phone(.*) /web$1 permanent;
      }
        #電腦首頁搜索
        if ($request_uri ~ ^/phone/search(.*)$) {
          rewrite ^(.*) /index.php?s=/home/phone/index.html last;
          break;
        }
        #手機首頁
        set $index false;
        if ($request_uri ~* ^/phone$) {
          set $index true;
        }
        if ($request_uri ~* ^/phone/$) {
          set $index true;
        }
        if ($index = true){
          rewrite ^/phone(.*) /index.php?s=/home/phone/index.html last;
          break;
        }
        #手機首頁分頁
        set $index_page false;
        if ($request_uri ~* ^/phone/pages/(\d*)$) {
          set $index_page true;
        }
        if ($request_uri ~* ^/phone/pages/(\d*)/$) {
          set $index_page true;
        }
        if ($index_page = true){
          rewrite ^/phone/pages/(\d*)(.*) /index.php?s=/home/phone/index/page/$1.html last;
          break;
        }
        #手機分類首頁
        set $cate false;
        if ($request_uri ~* ^/phone/cates/(\d*)$) {
          set $cate true;
        }
        if ($request_uri ~* ^/phone/cates/(\d*)/$) {
          set $cate true;
        }
        if ($cate = true){
          rewrite ^/phone/cates/(\d*) /index.php?s=/home/phone/index/cate/$1.html last;
          break;
        }
        #手機分類分頁
        set $cate_page false;
        if ($request_uri ~* ^/phone/cates/(\d*)/pages/(\d*)$) {
          set $cate_page true;
        }
        if ($request_uri ~* ^/phone/cates/(\d*)/pages/(\d*)/$) {
          set $cate_page true;
        }
        if ($cate_page = true){
          rewrite ^/phone/cates/(\d*)/pages/(\d*)(.*) /index.php?s=/home/phone/index/cate/$1/page/$2.html last;
          break;
        }
        #手機書籍頁面
        set $book false;
        if ($request_uri ~* ^/phone/books/(\d*)$) {
          set $book true;
        }
        if ($request_uri ~* ^/phone/books/(\d*)/$) {
          set $book true;
        }
        if ($book = true){
          rewrite ^/phone/books/(\d*)(.*) /index.php?s=/home/phone/books/book/$1.html last;
          break;
        }
        #手機書籍分頁頁面
        set $book false;
        if ($request_uri ~* ^/phone/books/(\d*)/pages/(\d*)$) {
          set $book true;
        }
        if ($request_uri ~* ^/phone/books/(\d*)/pages/(\d*)/$) {
          set $book true;
        }
        if ($book = true){
          rewrite ^/phone/books/(\d*)/pages/(\d*) /index.php?s=/home/phone/books/book/$1/page/$2.html last;
          break;
        }
        #手機章節頁面
        set $chapter false;
        if ($request_uri ~* ^/phone/books/(\d*)/chapters/(.*)$) {
          set $chapter true;
        }
        if ($request_uri ~* ^/phone/books/(\d*)/chapters/(.*)/$) {
          set $chapter true;
        }
        if ($chapter = true){
          rewrite ^/phone/books/(\d*)/chapters/(.*)/ /index.php?s=/home/phone/contents/books/$1/chapters/$2.html last;
          break;
        }

        if (!-e $request_filename) {
          return 404;
        }
    }
    location ~ .xml(.*) {
      root html/ttt/;
    }
 
    location ~ .txt(.*) {
      root html/ttt/;
    }
    location ~ .gif(.*) {
      root html/ttt/;
    }
    location ~ .jpg(.*) {
      root html/ttt/;
    }
    location ~ .css(.*) {
      root html/ttt/;
    }
    location ~ .js$ {
      root html/ttt/;
    }
    location ~ .php$ {
      root html/ttt;
      fastcgi_pass 127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_buffers 8 256k;
      fastcgi_connect_timeout 300s;
      fastcgi_send_timeout 300s;
      fastcgi_read_timeout 300s;
      fastcgi_param script_filename $document_root$fastcgi_script_name;
      include fastcgi_params;
    }
  }

關于“nginx怎么配置偽靜態和適配客戶端”這篇文章的內容就介紹到這里,感謝各位的閱讀!相信大家對“nginx怎么配置偽靜態和適配客戶端”知識都有一定的了解,大家如果還想學習更多知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

明溪县| 定远县| 安丘市| 清流县| 杨浦区| 堆龙德庆县| 台江县| 盘锦市| 敦煌市| 绥中县| 仁怀市| 准格尔旗| 雷波县| 百色市| 赤城县| 信丰县| 腾冲县| 磐石市| 芦溪县| 丹凤县| 澎湖县| 保定市| 苏尼特右旗| 临湘市| 犍为县| 沙坪坝区| 兴文县| 东方市| 会宁县| 西和县| 盐源县| 湖北省| 仙游县| 阿尔山市| 巴楚县| 万源市| 绍兴县| 札达县| 沅陵县| 佛教| 思南县|