<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                **規則:** ~~~ RewriteRule 虛擬訪問網頁 真實網頁 ~~~ 1.把index.html重定向到index.php ~~~ RewriteEngine On ReWriteRule ^index.html$? /index.php ~~~ 效果: ~~~ 訪問www.test.com/index.html效果等于www.test.com/index.php ~~~ ? 2.把index重定向到index.php ~~~ RewriteEngine On ReWriteRule ^index$? /index.php ~~~ 效果: ~~~ 訪問www.test.com/index效果等于www.test.com/index.php ~~~ ? 3.根目錄下的PHP文件,用html后綴也能訪問 寫法1: ``` RewriteEngine On ReWriteRule ^([a-zA-Z0-9_]{1,}).html$? /$1.php ``` 效果: ``` 訪問www.test.com/index.html效果等于www.test.com/index.php 訪問www.test.com/abc.html效果等于www.test.com/abc.php ``` 4.根目錄下的php文件,直接訪問文件名效果一樣 ``` RewriteEngine On ReWriteRule ^([a-zA-Z0-9_]{1,})$? /$1.php ``` 效果: ``` 訪問www.test.com/index效果等于www.test.com/index.php 訪問www.test.com/abc效果等于www.test.com/abc.php ``` ? 5.訪問文件名+html效果等效后綴為php的文件 ``` RewriteEngine On Options -Indexes RewriteRule ^/?([a-z/]+)\.html$ $1.php [NC] ``` 效果:    ``` 訪問www.test.com/index.html效果等于www.test.com/index.php 訪問www.test.com/abc/abc.html效果等于www.test.com/abc/abc.php ``` 6.訪問所有目錄下的文件等效于訪問文件名+后綴 ``` RewriteEngine On Options -Indexes RewriteRule ^/?([a-z/]+)$ $1.php [NC] ``` 效果: ``` 訪問www.test.com/index效果等于www.test.com/index.php 訪問www.test.com/abc/abc效果等于www.test.com/abc/abc.php ``` 7.404頁面跳轉設置 目標:當用戶訪問我們不存在的頁面時候,把網站內容跳轉到404頁面。在這里,我把404.html作為404頁面,放在網站的根目錄。 ``` RewriteEngine On Options -Indexes ErrorDocument 404 /404.html ``` 8. ~~~ RewriteRule ^test([0-9]*).html$ test.php?id=$1 ~~~ 效果: ~~~ http://www.xxx.com/test8.html -> http://www.xxx.com/test.php?id=8 ~~~ 9 ~~~ RewriteRule ^cat-([0-9]+)-([0-9]+)\.html$ cat.php?id1=$1&id2=$2 ~~~ 效果哦 ~~~ http://www.xxx.com/cat-1-3.html -> http://www.xxx.com/cat.php?id1=1&id2=3 ~~~ 10 ~~~ RewriteRule ^cat-([a-zA-Z0-9\-]*)-([0-9]+)-([0-9]+)\.html$ cat.php?id0=$1&id1=$2&id2=$3 ~~~ 效果 ~~~ http://www.xxx.com/cat-zbc2ac-3-5.html -> http://www.xxx.com/cat.php?id0=zbc2ac&id1=3&id2=5 ~~~ 11 ~~~ RewriteRule ^cat1-([0-9]+)-([0-9]+)-([0-9]+)\.html$ cat1.php?id1=$1&id2=$2&id3=$3 ~~~ 效果 ~~~ http://www.xxx.com/cat1-4-3-8.html -> http://www.xxx.com/cat1.php?id1=4&id2=3&id3=8 ~~~ 12 ~~~ RewriteRule ^cat([0-9]*)/$ cat.php?id1=$1 ~~~ 效果 ~~~ http://www.xxx.com/cat5/ -> http://www.xxx.com/cat.php?id1=5 ~~~ 13 ~~~ RewriteRule ^catm([0-9]*)/([0-9]*)/$ catm.php?id1=$1&id2=$2 ~~~ 效果 ~~~ http://www.xxx.com/catm6/3/ -> http://www.xxx.com/catm.php?id1=6&id2=3 ~~~ 防止盜鏈,如果來得要訪問jpe jpg bmp png結尾的url 用戶不是來自我們的網站,那么讓他看一張我們網站的展示圖片。 ``` RewriteEngine OnRewriteCond %{HTTP_REFERER} !^http://(.+.)?mysite.com/ [NC]RewriteCond %{HTTP_REFERER} !^$RewriteRule .*.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpg [L] ``` 網站升級的時候,只有特定IP才能訪問,其他的用戶將看到一個升級頁面 ``` RewriteEngine onRewriteCond %{REQUEST_URI} !/upgrade.html$RewriteCond %{REMOTE_HOST} !^24\.121\.202\.30 RewriteRule $ http://www.linuxidc.com/upgrade.html [R=302,L] ``` 把老的域名轉向新域名 ``` # redirect from old domain to new domainRewriteEngine OnRewriteRule ^(.*)$http://www.yourdomain.com/$1[R=301,L] ``` 例子 ``` RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] ``` * 第一行、將RewriteEngine引擎設置為on,就是讓url重寫生效; * 第二行、?如果文件存在,就直接訪問文件,不進行下面的RewriteRule. * 第三行、?如果目錄存在就直接訪問目錄不進行RewriteRule * 同理:?RewriteCond?%{REQUEST\_URI}?!^.\*(\\.css|\\.js|\\.gif|\\.png|\\.jpg|\\.jpeg)$?#如果是這些后綴的文件,就直接訪問文件,不進行Rewrite * 第四行、配置url重寫規則,!^(index\\.php|images|robots\\.txt) 這個正則表達式指明了哪些文件不需要重寫,而是直接訪問; * 第五行、^(.\*)$是一個正則表達式,意思是對所有請求都發送到/index.php/$1,熟悉url的人都知道,以反斜杠(/)開頭的,都是相對路徑,相對于誰呢?根,也就是網址。 原來自己到網站訪問到URL是這樣到:http://網址/index.php?/控制器/函數,現在想去掉index.php?,這里index.php后面還多了一個問號,好煩人的,結果文件建好后,輸入網址訪問,報了nginx 404錯誤,我的nginx是1.4.7版本 后來經過多方尋找,終于搞定了,打開nginx到配置文件nginx.conf,在server 部分加入以下命令 ?if (!-e $request\_filename) {? ? ? ? rewrite ^.\*$ /index.php last;? ? ? } 保存后,重啟nginx (/etc/init.d/nginx restart) ,再輸入沒有帶index.php?的網址,真到可以訪問了
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看