用url重新一般都是使用URLRewriter库,基本上都是一些配置,在webconfig中

首先配置configuration节点

<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler,URLRewriter" />
</configSections>

<system.web>节点下配置httpHandlers和httpModules,二者配置其一即可

httpModules配置

    <httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>

httpHandlers配置

    <httpHandlers>
<add verb="*" path="/*/list/*" type="URLRewriter.RewriterFactoryHandler,URLRewriter" />
<add verb="*" path="/group/*" type="URLRewriter.RewriterFactoryHandler,URLRewriter" />
</httpHandlers>

<remove verb = "* " path = "*.asmx " />
    <add verb = "* " path = "* " type = "URLRewriter.RewriterFactoryHandler, URLRewriter" />
     <add verb = "* " path = "*.html " type =" URLRewriter.RewriterFactoryHandler, URLRewriter " />

<system.webServer>节点下添加

<handlers>
<add name="Rewriter" path="*" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None"
preCondition="classicMode,runtimeVersionv4.0,bitness32" />
</handlers>

接下来就是写规则了。在webconfig的configuration内部的最底部添加RewriterConfig节点,并写规则

<!--url重写规则-->
<RewriterConfig>
<Rules>
<!--店铺-->
<RewriterRule>
<LookFor>~/(.*)/list/(.*)</LookFor>
<SendTo>~/group/itemlist.aspx?name=$1&amp;keyword=$2</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/group/(.*)</LookFor>
<SendTo>~/group/circle.aspx?name=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>

这些基本上已经好了。但发布到iis上还需配置一些东西。即处理映射

选择你发布的网站。选择"处理程序映射"

然后:

选择路径:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll

保存即可。

用URLRewriter重写url的更多相关文章

  1. 利用URLRewriter重写url地址

    首先,当然是下载URLRewriter了 download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/MSDN ...

  2. 在Apache中使用mod_rewrite模块重写URL

    如果有使用第三方框架做项目时,url路径是可以同过框架给的方法来设定的(如thinkphp),但如果使用原生php写的项目又想重写url,则可通过apache的一些设置来达到想要的效果. 在更改apa ...

  3. HttpContext.Current.RewritePath方法重写URL

    if (!IsPostBack) { //如果请求ID为空,则重写URL为:~/index.aspx?ID=shouji.115sou.com if (Request.QueryString[&quo ...

  4. 在js中获取query string 以及重写URL的函数

    函数用途:如标题.1. 从URL中解析出參数,2.重写URL中的參数值 例如以下代码所看到的.包括了測试.能够直接copy到浏览器中,输入測试地址:localhost:xxx?a=1&b=2& ...

  5. 【转载】ASP.NET MVC重写URL制作伪静态网页,URL地址以.html结尾

    在搜索引擎优化领域,静态网页对于SEO的优化有着很大的好处,因此很多人就想把自己的网站的一些网页做成伪静态.我们现在在网络上发现很多博客网站.论坛网站.CMS内容管理系统等都有使用伪静态这一种情况,伪 ...

  6. asp.net 重写URL方法和封装好的DLL

    .net 重写URL方法和封装好的DLL URL重写方法DLL(2.0)

  7. jsp重写url

    众所周知,使用java web编程出来的网站都是.jsp结尾的,而别人的网站都是以.html结尾的,那么这种效果是怎么实现的呢?就是这篇文章产生的原因,jsp重写url需要设计到第三方架包urlrew ...

  8. ASP.NET URLRewriter重写

    URLRewriter重写是微软官方出的第三方重写插件 下载地址:http://download.csdn.net/detail/ysn1314/5421587 下载后在项目中添加引用,然后再配置文件 ...

  9. apache重写URL时,排除静态资源

    THINKPHP项目部署的apache 上面时,如果为了隐藏入口文件配置了重写URL,会导致将静态资源的URL也解析成Controller/Method,导致触发模块不存在 所以在URL重写配置中,需 ...

随机推荐

  1. 对iphone手机IMU的陀螺仪、加速度计、图像的时间戳做对齐处理

    https://blog.csdn.net/chishuideyu/article/details/77479758 加速度计和陀螺仪的时间戳一致 ros 的message filters可以做时间同 ...

  2. nvidia-smi failed because it couldn't communicate with the nvidia driver

    Ubuntu装好CUDA之后过段时间提示NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. NV ...

  3. express+gulp+gulp-nodemon+browser-sync自动刷新

    express自动生成项目.不在赘述 1.在项目根目录下新建终端,依次运行如下命令 npm install gulp --save-dev npm install gulp-nodemon --sav ...

  4. 指数级计算复杂度 调用Fibonacci函数次数

    指数级计算复杂度 计算调用次数 #include <stdio.h> long fibonacciCallTimes(long n); int main(void) { long resu ...

  5. 数据在内存中的存储方式( Big Endian和Little Endian的区别 )(x86系列则采用little endian方式存储数据)

    https://www.cnblogs.com/renyuan/archive/2013/05/26/3099766.html 1.故事的起源 “endian”这个词出自<格列佛游记>.小 ...

  6. CSS盒子模型(简要了解)

    CSS中, Box Model叫盒子模型(或框模型),Box Model规定了元素框处理元素内容(element content).内边距(padding).边框(border) 和 外边距(marg ...

  7. LeetCode 617 Merge Two Binary Trees 解题报告

    题目要求 Given two binary trees and imagine that when you put one of them to cover the other, some nodes ...

  8. P4491 [HAOI2018]染色

    题目链接:洛谷 题目大意:$n$个位置染$m$种颜色,如果出现次数恰为$S$次的颜色有$k$种,则对答案有$W_k$的贡献,求所有染色方案的答案之和$\bmod 1004535809$. 数据范围:$ ...

  9. 批量删除以及将String数组转换成Integer数组的奇淫技巧

    首先在pom.xml文件添加依赖: <!-- bean工具 --> <dependency> <groupId>commons-beanutils</grou ...

  10. vue package-lock.json的作用

    其实用一句话来概括很简单,就是锁定安装时的包的版本号,并且需要上传到git,以保证其他人在npm install时大家的依赖能保证一致.