华域联盟 .Net aspx文件格式使用URLRewriter实现静态化变成html

aspx文件格式使用URLRewriter实现静态化变成html

使用asp.net 开发的网页程序,使用URLRewriter.dll 实现静态化。

A. 下载URLRewriter.rar,解压后放在/bin/目录下

B. 将URLRewriter.rar 加入工程引用。

C. 配置IIS 站点,将扩展名为html 指向处理程序aspnet_isapi.dll。

IIS 站点->属性->主目录->配置->添加

可执行文件和aspx 处理相同,都是 c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll

特别注意,一定不要选择检查文件是否存在。

D. 在web.config 中添加配置内容,压缩包里有。

复制代码 代码如下:

<configSections>

<section name="RewriterConfig"

type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />

</configSections>

<!-- 实际重定向-->

<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 静态化Apache Web Server 的配置(conf/httpd.conf )

A. 在httpd.conf 文件中查找LoadModule rewrite_module modules/mod_rewrite.so

通常该行被注释,去掉“#”。如果没有就增加该行。

B. 加入代码:

复制代码 代码如下:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteRule ^/([0-9]+).html$ /user.php?user=$1

</IfModule>

C. 如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置文件.htccess 中去,否则可能

无法使用。

D. 重启Apache,重新载入配置。

E. 在地址栏输入[url]http://localhost/1.html[/url] ,实际指向[url]http://localhost/user.php?user=1[/url]

您可能感兴趣的文章:

  • 比较详细的Asp伪静态化方法及Asp静态化探讨
  • 不用mod_rewrite直接用php实现伪静态化页面代码
  • 网页的HTML静态化_网站优化之谈
  • 通用大型网站页面静态化解决方案
  • php 静态化实现代码
  • asp 网站静态化函数代码html
  • nginx 伪静态化rewrite规则
  • ASP页面静态化批量生成代码分享(多种方法)
  • php静态化页面 htaccess写法详解(htaccess怎么写?)
  • smarty 缓存控制前的页面静态化原理
  • php页码形式分页函数支持静态化地址及ajax分页
  • 使用ob系列函数实现PHP网站页面静态化
  • 分享常见的几种页面静态化的方法
  • 如何对ASP.NET网站实现静态化

本文由 华域联盟 原创撰写:华域联盟 » aspx文件格式使用URLRewriter实现静态化变成html

转载请保留出处和原文链接:https://www.cnhackhy.com/48899.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部