1. 程式人生 > >IIS+asp的偽靜態配置

IIS+asp的偽靜態配置

開發環境

os:Windows server03

伺服器:IIS5.0

指令碼:asp

偽靜態的好處(省略,google一下“偽靜態”,你便知道它的價值了)

偽靜態的流程:

首先我們需要下載一個ISAPI_Rewrite,有精簡版和完全版,一般精簡版只能對伺服器全域性進行配置,而完整版可以對伺服器上的各個網站進行偽靜態配置。對於個人站長來說,精簡版就足夠了。

網上流傳著很多設定版本大多數是針對完全版的,這個是要收費的,好在有45天的試用時間,其實使用lite版本的進行測試也完全可以,它與完全版本的區別如下: 本人摘抄了一部分供大家參考,如下所示:

Lite version limitations

Lite version of ISAPI_Rewrite shares the same rewrite engine and features but with the following limitations:

  • No support for distributed .htaccess configurations, directory and web site level configurations. Only one global httpd.conf configuration file will be loaded from Lite version installation folder.
  • No support for <VirtualHost>, <Directory>, <DirectoryMatch>, <Files>, <FilesMatch>, <Location> and <LocationMatch> tags.
  • There is no proxy module in Lite version, thus all proxy related functions like RewriteProxy directive and [P] flag will be ignored.
  • No manual installation package for Lite version to install in a shared hosting environment.

ISAPI_Rewrite Lite is completely free and it is a good solution for development or testing purposes and for small servers that host only a few web sites and don’t require distributed configurations or proxy functions.

最重要的地方就是配置檔案是httpd.conf,而不是完全版中的http.ini。這個非常重要,我當時安裝lite版本之後就一直在尋找http.ini,結果白忙了,辛苦在官網上看了一下。

提示:如果不知道自己安裝在哪裡,就是用搜索工具搜一下,呵呵。

然後,開啟Internet 資訊服務,右鍵,web站點屬性,點選ISAPI篩選器選項卡.新增篩選器,這裡的名稱可以自己隨意填寫比如mytest,路徑指定ISAPI_Rewrite.dll,確定。重啟IIS伺服器。

最後,我使用一個網上的例子,實際上在我這邊執行的時候有問題,所以我改進了一下。

 下面我們先做一個測試頁new.asp,可以按照下面的程式碼寫  <%=request.querystring("id")%>

  然後,在瀏覽器中輸入:

  http://127.0.0.1/new.asp?id=1234

  接著你就可以在網頁上看到一行文字:“1234”

  看到這幾個數字,就說明你測試成功了。

  現在我們開始來配置ISAPI_Rewrite :

  開啟ISAPI_Rewrite的目錄,然後開啟httpd.conf檔案,然後新增這一句:

  RewriteRule /new_([0-9,a-z]*).html /new.asp?id=$1

  儲存後,我們就可以測試一下這個網址了:http://127.0.0.1/new_1234.html

  可以看到頁面上的“1234”了吧,就這樣偽靜態配置成功了!

注意:$1是網上有問題的地方,$1代表的是前面匹配的引數。