久久久久久久性爱潮,国产又粗又猛又爽又黄下载视频,尤物国产在线一区视频,欧美日本国产在线不卡

<sup id="4uqqy"><ol id="4uqqy"></ol></sup>
  • <th id="4uqqy"></th>

      • <strike id="4uqqy"><nobr id="4uqqy"><ins id="4uqqy"></ins></nobr></strike><sup id="4uqqy"></sup><strong id="4uqqy"><u id="4uqqy"></u></strong>
        <sub id="4uqqy"></sub>

          綠色資源網(wǎng):您身邊最放心的安全下載站! 最新軟件|熱門(mén)排行|軟件分類|軟件專題|廠商大全

          綠色資源網(wǎng)

          技術(shù)教程
          您的位置:首頁(yè)服務(wù)器類Web服務(wù)器 → Nginx rewrite偽靜態(tài)配置及參數(shù)詳解

          Nginx rewrite偽靜態(tài)配置及參數(shù)詳解

          我要評(píng)論 2012/09/27 21:03:23 來(lái)源:綠色資源網(wǎng) 編輯:www.kiwanis-srv.org [ ] 評(píng)論:0 點(diǎn)擊:211次

          nginx rewrite 偽靜態(tài)配置參數(shù)和使用例子 附正則使用說(shuō)明

          正則表達(dá)式匹配,其中:

          1. * ~ 為區(qū)分大小寫(xiě)匹配
          2. * ~* 為不區(qū)分大小寫(xiě)匹配
          3. * !~和!~*分別為區(qū)分大小寫(xiě)不匹配及不區(qū)分大小寫(xiě)不匹配

          文件及目錄匹配,其中:

          1. * -f和!-f用來(lái)判斷是否存在文件
          2. * -d和!-d用來(lái)判斷是否存在目錄
          3. * -e和!-e用來(lái)判斷是否存在文件或目錄
          4. * -x和!-x用來(lái)判斷文件是否可執(zhí)行

          flag標(biāo)記有:

          1. * last 相當(dāng)于Apache里的[L]標(biāo)記,表示完成rewrite
          2. * break 終止匹配, 不再匹配后面的規(guī)則
          3. * redirect 返回302臨時(shí)重定向 地址欄會(huì)顯示跳轉(zhuǎn)后的地址
          4. * permanent 返回301永久重定向 地址欄會(huì)顯示跳轉(zhuǎn)后的地址

          一些可用的全局變量有,可以用做條件判斷(待補(bǔ)全)

          1. $args
          2. $content_length
          3. $content_type
          4. $document_root
          5. $document_uri
          6. $host
          7. $http_user_agent
          8. $http_cookie
          9. $limit_rate
          10. $request_body_file
          11. $request_method
          12. $remote_addr
          13. $remote_port
          14. $remote_user
          15. $request_filename
          16. $request_uri
          17. $query_string
          18. $scheme
          19. $server_protocol
          20. $server_addr
          21. $server_name
          22. $server_port
          23. $uri

          結(jié)合QeePHP的例子

          1. if (!-d $request_filename) {
          2. rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/?(.*)$ /index.php?namespace=user&controller=$1&action=$2&$3 last;
          3. rewrite ^/([a-z-A-Z]+)/?$ /index.php?namespace=user&controller=$1 last;
          4. break;

          多目錄轉(zhuǎn)成參數(shù)
          abc.domian.com/sort/2 => abc.domian.com/index.php?act=sort&name=abc&id=2

          1. if ($host ~* (.*)\.domain\.com) {
          2. set $sub_name $1;
          3. rewrite ^/sort\/(\d+)\/?$ /index.php?act=sort&cid=$sub_name&id=$1 last;
          4. }

          目錄對(duì)換
          /123456/xxxx -> /xxxx?id=123456

          1. rewrite ^/(\d+)/(.+)/ /$2?id=$1 last;

          例如下面設(shè)定nginx在用戶使用ie的使用重定向到/nginx-ie目錄下:

          1. if ($http_user_agent ~ MSIE) {
          2. rewrite ^(.*)$ /nginx-ie/$1 break;
          3. }

          目錄自動(dòng)加“/”

          1. if (-d $request_filename){
          2. rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
          3. }

          禁止htaccess

          1. location ~/\.ht {
          2. deny all;
          3. }

          禁止多個(gè)目錄

          1. location ~ ^/(cron|templates)/ {
          2. deny all;
          3. break;
          4. }

          禁止以/data開(kāi)頭的文件
          可以禁止/data/下多級(jí)目錄下.log.txt等請(qǐng)求;

          1. location ~ ^/data {
          2. deny all;
          3. }

          禁止單個(gè)目錄
          不能禁止.log.txt能請(qǐng)求

          1. location /searchword/cron/ {
          2. deny all;
          3. }

          禁止單個(gè)文件

          1. location ~ /data/sql/data.sql {
          2. deny all;
          3. }

          給favicon.ico和robots.txt設(shè)置過(guò)期時(shí)間;
          這里為favicon.ico為99 天,robots.txt為7天并不記錄404錯(cuò)誤日志

          1. location ~(favicon.ico) {
          2. log_not_found off;
          3. expires 99d;
          4. break;
          5. }
          6.  
          7. location ~(robots.txt) {
          8. log_not_found off;
          9. expires 7d;
          10. break;
          11. }

          設(shè)定某個(gè)文件的過(guò)期時(shí)間;這里為600秒,并不記錄訪問(wèn)日志

          1. location ^~ /html/scripts/loadhead_1.js {
          2. access_log off;
          3. root /opt/lampp/htdocs/web;
          4. expires 600;
          5. break;
          6. }

          文件反盜鏈并設(shè)置過(guò)期時(shí)間
          這里的return 412 為自定義的http狀態(tài)碼,默認(rèn)為403,方便找出正確的盜鏈的請(qǐng)求
          “rewrite ^/ http://leech.c1gstudio.com/leech.gif;”顯示一張防盜鏈圖片
          “access_log off;”不記錄訪問(wèn)日志,減輕壓力
          “expires 3d”所有文件3天的瀏覽器緩存

          1. location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip|css|js)$ {
          2. valid_referers none blocked *.c1gstudio.com *.c1gstudio.net localhost 208.97.167.194;
          3. if ($invalid_referer) {
          4. rewrite ^/ http://leech.c1gstudio.com/leech.gif;
          5. return 412;
          6. break;
          7. }
          8. access_log off;
          9. root /opt/lampp/htdocs/web;
          10. expires 3d;
          11. break;
          12. }

          只充許固定ip訪問(wèn)網(wǎng)站,并加上密碼

          1. root /opt/htdocs/www;
          2. allow 208.97.167.194;
          3. allow 222.33.1.2;
          4. allow 231.152.49.4;
          5. deny all;
          6. auth_basic "C1G_ADMIN";
          7. auth_basic_user_file htpasswd;

          將多級(jí)目錄下的文件轉(zhuǎn)成一個(gè)文件,增強(qiáng)seo效果
          /job-123-456-789.html 指向/job/123/456/789.html

          1. rewrite ^/job-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /job/$1/$2/jobshow_$3.html last;

          將根目錄下某個(gè)文件夾指向2級(jí)目錄
          如/shanghaijob/ 指向 /area/shanghai/
          如果你將last改成permanent,那么瀏覽器地址欄顯是 /location/shanghai/

          1. rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;

          上面例子有個(gè)問(wèn)題是訪問(wèn)/shanghai 時(shí)將不會(huì)匹配

          1. rewrite ^/([0-9a-z]+)job$ /area/$1/ last;
          2. rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;

          這樣/shanghai 也可以訪問(wèn)了,但頁(yè)面中的相對(duì)鏈接無(wú)法使用,
          如./list_1.html真實(shí)地址是/area /shanghia/list_1.html會(huì)變成/list_1.html,導(dǎo)至無(wú)法訪問(wèn)。

          那我加上自動(dòng)跳轉(zhuǎn)也是不行咯
          (-d $request_filename)它有個(gè)條件是必需為真實(shí)目錄,而我的rewrite不是的,所以沒(méi)有效果

          1. if (-d $request_filename){
          2. rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
          3. }

          知道原因后就好辦了,讓我手動(dòng)跳轉(zhuǎn)吧

          1. rewrite ^/([0-9a-z]+)job$ /$1job/ permanent;
          2. rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;

          文件和目錄不存在的時(shí)候重定向:

          1. if (!-e $request_filename) {
          2. proxy_pass http://127.0.0.1;
          3. }

          域名跳轉(zhuǎn)

          1. server
          2. {
          3. listen 80;
          4. server_name jump.c1gstudio.com;
          5. index index.html index.htm index.php;
          6. root /opt/lampp/htdocs/www;
          7. rewrite ^/ http://www.c1gstudio.com/;
          8. access_log off;
          9. }

          多域名轉(zhuǎn)向

            關(guān)鍵詞:Nginx,rewrite,偽靜態(tài)

          閱讀本文后您有什么感想? 已有 人給出評(píng)價(jià)!

          • 0 歡迎喜歡
          • 0 白癡
          • 0 拜托
          • 0 哇
          • 0 加油
          • 0 鄙視