溫馨提示×

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

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

aspx文件格式如何使用URLRewriter實(shí)現(xiàn)靜態(tài)化變成html

發(fā)布時(shí)間:2021-10-13 10:00:08 來(lái)源:億速云 閱讀:84 作者:小新 欄目:開發(fā)技術(shù)

這篇文章給大家分享的是有關(guān)aspx文件格式如何使用URLRewriter實(shí)現(xiàn)靜態(tài)化變成html的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

使用asp.net 開發(fā)的網(wǎng)頁(yè)程序,使用URLRewriter.dll 實(shí)現(xiàn)靜態(tài)化。
A. 下載URLRewriter.rar,解壓后放在/bin/目錄下
B. 將URLRewriter.rar 加入工程引用。
C. 配置IIS 站點(diǎn),將擴(kuò)展名為html 指向處理程序aspnet_isapi.dll。
IIS 站點(diǎn)->屬性->主目錄->配置->添加
可執(zhí)行文件和aspx 處理相同,都是 c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
特別注意,一定不要選擇檢查文件是否存在。
D. 在web.config 中添加配置內(nèi)容,壓縮包里有。

復(fù)制代碼 代碼如下:


<configSections>
<section name="RewriterConfig"
type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<!-- 實(shí)際重定向-->
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\d*).html</LookFor>
<SendTo>~/user/default.aspx?link=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<system.web>
<!--
需要在IIS 里面增加html 引用,改成aspx 的引用
-->
<httpHandlers>
<add verb="*" path="*.aspx"
type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.html"
type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
</httpHandlers>


E. 在地址欄輸入[url]http://localhost/1.html[/url] 指向[url]http://localhost/user/default.aspx?link=1[/url]

基于Apache HTTP Server 靜態(tài)化Apache Web Server 的配置(conf/httpd.conf )
A. 在httpd.conf 文件中查找LoadModule rewrite_module modules/mod_rewrite.so
通常該行被注釋,去掉“#”。如果沒(méi)有就增加該行。
B. 加入代碼:

復(fù)制代碼 代碼如下:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/([0-9]+).html$ /user.php?user=$1
</IfModule>


C. 如果網(wǎng)站使用通過(guò)虛擬主機(jī)來(lái)定義,請(qǐng)務(wù)必加到虛擬主機(jī)配置文件.htccess 中去,否則可能
無(wú)法使用。
D. 重啟Apache,重新載入配置。
E. 在地址欄輸入[url]http://localhost/1.html[/url] ,實(shí)際指向[url]http://localhost/user.php?user=1[/url]

感謝各位的閱讀!關(guān)于“aspx文件格式如何使用URLRewriter實(shí)現(xiàn)靜態(tài)化變成html”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI