<form id="fbxrn"><thead id="fbxrn"></thead></form>

      您現在的位置是:首頁 > 建站知識建站知識

      巧用偽靜態解決虛擬主機不支持綁定到子目錄的問題

      AndyGuo2020-05-05 12:05:40建站知識2735人已圍觀

      簡介我們知道一般虛擬主機是不支持綁定到子目錄的,這時候該怎么辦呢。

      我們知道一般虛擬主機是不支持綁定到子目錄的,這時候該怎么辦呢。

      我們可以利用偽靜態實現將域名或二級域名綁定到子目錄,

      如果是Apache環境,在站點根目錄新建一個文件命名為:.htaccess

      下面是 123.d163.net域名綁定到子目錄dh

      RewriteEngine On
      RewriteBase /
        
      # 綁定123.d163.net 到子目錄dh
      
      RewriteCond %{HTTP_HOST} ^123\.d163\.net$ [NC]
      RewriteCond %{REQUEST_URI} !^/dh/
      RewriteRule ^(.*)$ dh/$1?Rewrite [L,QSA]
      
      #可以綁定多個 只需重復上三行代碼并更改一下域名、目錄名 就好了  

      如果是windows服務器,在站點根目錄新建web.config文件

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration>
          <system.webServer>
              <rewrite>
                  <rules>
                      <rule name="Imported Rule 1" stopProcessing="true">
                          <match url="^(.*)$" ignoreCase="false" />
                          <conditions logicalGrouping="MatchAll">
                              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                              <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                          </conditions>
                          <action type="Rewrite" url="index.php?s={R:1}" appendQueryString="true" />
                      </rule>
                      <rule name="Imported Rule 2" stopProcessing="true">
                          <match url="^(.*)$" ignoreCase="false" />
                          <conditions logicalGrouping="MatchAll">
                              <add input="{HTTP_HOST}" pattern="^123\.d163\.net$" />
                              <add input="{URL}" pattern="^/dh/" ignoreCase="false" negate="true" />
                          </conditions>
                          <action type="Rewrite" url="dh/{R:1}?Rewrite" appendQueryString="true" />
                      </rule>
                  </rules>
              </rewrite>
          </system.webServer>
      </configuration>

      完成以上步驟就可以實現訪問123.d163.net而直接訪問子目錄dh了(子目錄dh中有index.html或index.php)

      小郭博客

      標簽云 更多

      高清性欧美暴力猛交BD_东北偷拍厕所XXXXX_国产+成+人+亚洲欧洲
      關閉
      QQ 微信 支付寶掃一掃打賞