IIS的ISAPI服务器扩展URL REWRITE(URL重写)

合集下载

IIS301重定向 URL Rewrite

IIS301重定向 URL Rewrite

IIS URL Rewrite – rewriting non-www to wwwIf you’re using IIS 7.0 (or 7.5), URL Rewrite is a valuable tool, well worth installing and using.One common use of URL Rewrite is redirecting to . Many people are doing this for search engine optimization (SEO) so that search engines only see the one site, rather than two sites. The goal is to set a permanent 301 redirect.You can download URL Rewrite from/expand/URLRewrite. For this walkthrough and screenshots I’ll use URL Rewrite 2.0 RC1, but everything that I’ll cover also works for version 1.0 and 1.1.URL Rewrite works at the global level, or site level (or application level for that matter). Where you apply it is really up to how you manage your server. Either will work for a domain name redirect like this.You can choose to create the rules using IIS Manager, or using a text editor and updating web.config directly. I’ll show both, starting with IIS Manager.Let’s get started. First, open IIS Manager and double-click on the “URL Rewrite” icon.Next, click on “Add Rules…” from the Actions pane.Here you’ll have a choice from a few wizard options, and with URL Rewrite 2.0 you can also create outbound rules. Create a Blank rule (inbound rules).Give your rule a good friendly “Name”.I’ll call mine “Redirect to www”.In the “Using”dropdown box you can choose between Regular Expressions and Wildcards. Use wildcards if you aren’t familiar with regular expressions since they are much more intuitive. However, if you later need to create more complex rules, regex may be necessary.For this demo select Wildcards. However, I’ll include instructions for those wanting to use regular expressions.Enter *for the “Pattern”. That means anything qualifies. We’ll use a condition later instead of matching to the URL. (for Regular Expressions, use .*).Now expand the “Conditions” section and click “Add”.In the “Add Condition” dialogue enter the following:Condition input: {HTTP_HOST}Check if inputMatches the Patternstring:Pattern: (for regex, enter ^$)Ignore case: checkedClick OK.Finally, it’s time to set the Action.In the Action secti on make sure that the “Action Type” is set to Redirect.For the “Action Properties”, enter /{R:0}. The {R:0} retains the existing URL so if someone typed something like /aboutus it would retain the aboutus as it adds the www.Be sure that the “Append query string” remains checked so that the querystring part is also retained.Also, be sure that the “Redirect Type” is set to Permanent (301), which is what the search engines like. This tells the search engines to do a permanent redirect, use the new location and ignore the previous location.Finally, Apply the rule and test!Using a Text EditorYou can also create this rule manually by adding the following to your site’s web.config (or applicationHost.config if you set this at the server level).In the <system.webServer> section of your web.config, add the following:Wildcards<rewrite><rules><rule name="Redirect to www"patternSyntax="Wildcard"stopProcessing="true"><match url="*"/><conditions><add input="{HTTP_HOST}"pattern=""/></conditions><action type="Redirect"url="/{R:0}"/></rule></rules></rewrite>Save and you should be set.Or, if you prefer Regular Expressions, use this instead:Regular Expressions<rewrite><rules><rule name="Redirect to www"patternSyntax="ECMAScript"stopProcessing="true"><match url=".*"/><conditions><add input="{HTTP_HOST}"pattern="^$"/></conditions><action type="Redirect"url="/{R:0}"/></rule></rules></rewrite>This is just the start to great SEO, but it’s a common step and one that I hope you find helpful./owscott/archive/2009/11/27/iis-url-rewrite-rewriting-non-www-to-www.asp x/downloads/en/details.aspx?FamilyID=c8d3e2a4-5d14-434b-a067-39a6 fb8b9311/downloads/en/details.aspx?FamilyID=1b8c7bd8-8824-4408-b8fc-49dc 7f951a00。

UrlRewritingNet完美实现.NETURL重写

UrlRewritingNet完美实现.NETURL重写

UrlRewritingNet完美实现.NETURL重写URL重写好处有很多,如有利于SEO、便于记忆、隐藏真实路径使安全性提高、便于更新等等。

本文概要描述了各种URL重写的实现。

2.0 中实现URL重写有很多方法,如:Global.asax中捕获用Application_BeginRequest请求,再用HttpContext类的Rewrite方法或Server.Transfer方法实现重写;自己实现IHttpModule实现重写;还有的利用服务器的404错误引导到新的页面实现重写;最后就是用组件实现重写(基本原理大多也是实现IHttpModule、IHttpHandler接口处理请求)。

如果自己处理请求,实现起来麻烦,特别是在大项目中,做好使用组件实现。

网上有很多开源或免费的实现URL重写的组件,选择余地特别大。

当初我选择的标准是小巧、快速、实现常用的URL重写功能。

经过比较选择了只有32KB大小的UrlRewritingNet。

查看其文档主要功能有以下一些:1.基于正则表达式的重写2.支持Themes和母版页3.支持输出缓存4.支持信任级别为"Medium"的使用环境5.支持Postback6.支持无Cookie的Session7.运行时添加、修改改写规则8.容易安装使用OK!功能完全够用,就选他了!(本系统使用的是支持.html的方法,即第二种配置)Web.config中的配置:<configuration><configSections><section name="urlrewritingnet"requirePermission ="false"type="UrlRewritingNet.Configuration.UrlRewriteSection, UrlRewritingNet.UrlRewriter" /></configSections><urlrewritingnetrewriteOnlyVirtualUrls="true"contextItemsPrefix="QueryString"defaultPage = "Default.aspx"defaultProvider="RegEx"xmlns="" ><rewrites><add name="RewritePhoto" virtualUrl="^~/(\d+).aspx"rewriteUrlParameter="ExcludeFromClientQueryString"destinationUrl="~/Default.aspx?ID=$1"ignoreCase="true" /><!--更多重写规则--></rewrites></urlrewritingnet><appSettings/><connectionStrings/><system.web><httpModules><add name="UrlRewriteModule"type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" /></httpModules><!--设置 compilation debug="true" 将调试符号插入已编译的页面中。

URL重定向和URL重写

URL重定向和URL重写

URL重定向和URL重写1、URL重定向URL重定向和URL重写之间的⽤词差异乍⼀看可能很细微,但这对于向客户端提供资源具有重要意义。

Core的URL重写中间件能够满⾜两者的需求。

URL重定向是客户端操作,指⽰客户端访问另⼀个地址的资源。

这需要往返服务器。

客户端对资源发出新请求时,返回客户端的重定向URL会出现在浏览器地址栏。

如果将 /resource 重定向到 /different-resource,客户端会请求 /resource。

服务器通过指⽰重定向是临时还是永久的状态代码作出响应,表⽰客户端应该获取 /different-resource 处的资源。

客户端在重定向URL处对资源执⾏新的请求。

将请求重定向到不同的URL时,可指定重定向是永久的还是临时的。

如果资源有⼀个新的永久性URL,并且你希望指⽰客户端所有将来的资源请求都使⽤新URL,则使⽤"301(永久移动)"状态代码。

收到301状态代码时,客户端可能会缓存响应。

如果重定向是临时的或⼀般会更改的,则使⽤"302(已找到)"状态代码,以使客户端将来不应存储和重⽤重定向URL。

2、URL重写URL 重写是服务器端操作,提供来⾃不同资源地址的资源。

重写URL不需要往返服务器。

重写的URL不会返回客户端,也不会出现在浏览器地址栏。

/resource 重写到 /different-resource 时,客户端会请求 /resource ,并且服务器会在内部提取 /different-resource 处的资源。

尽管客户端可能能够检索已重写URL处的资源,但是,客户端发出请求并收到响应时,并不会知道已重写URL处存在的资源。

iis中ISAPIRewrite实现php伪静态WEB服务器 电脑资料

iis中ISAPIRewrite实现php伪静态WEB服务器 电脑资料

iis中ISAPIRewrite实现php伪静态WEB效劳器电脑资料本文介绍在iis中通过ISAPIRewrite实现php伪静态的方法,感兴趣的朋友参考下,有些windows主机中,iis不支持.htaess 文件,如果是本地机器,apmserv效劳器可以用.htaess 文件,用apmserv效劳器环境配置伪静态,请参考文章:php伪静态配置之url rewrite实例教程。

这里主要介绍下d.ini配置php伪静态的方法。

例如,.myhack58./index.php可以用.myhack58./ 来直接访问。

.myhack58./newxx.php?=10 [newxx.php 是的详细页面]伪静态成为 .myhack58./new-10.html实现过程,d.ini 源文件:复制代码代码例如:[ISAPIRewrite]# 3600 = 1 hour# CacheClockRate 3600RepeatLimit 32# Protect d.ini and d.parse.errors files# from aessing throughRewriteRule ^/d(?:\.ini|\.parse\.errors).* [F,I,O] RewriteRule / /index.phpRewriteRule /new-([0-9]+).html$ /newxx\.php\?uid=$1 以上例子可以看出 RewriteRule / /index.php 是把index.php 转换为index.htmlRewriteRule /new-([0-9]+).html$ /newxx\.php\?uid=$1 转换为new-10{这个10为id=几的值}.html以上介绍了iis中在.ini中配置php伪静态的方法,希望对大家有所帮助,模板,内容仅供参考。

IIS7.5使用URLRewrite模块的简单设置实现网页跳转

IIS7.5使用URLRewrite模块的简单设置实现网页跳转

IIS7.5使⽤URLRewrite模块的简单设置实现⽹页跳转我们都知道Apache可以在配置⽂件⾥⽅便的设置针对⽹页或⽹站的rewrite,但是最近接⼿了⼀组IIS服务器,发现这货简单的没有配置⽂件可让我写,但是我却要实现⽹页rewrite的功能。

怎么办呢,google了⼀下,果断的找到了内容。

IIS URL Rewrite模块:将安装包下载到IIS服务器上,安装,它会⾃动检测IIS的安装位置,很简单直到最后finish结束,之后,重新打开IIS Manager,就会在每⼀个⽹站的⽬录下清楚地看到⼀个组件:URL Rewrite!双击,进⼊它的规则⾯板:可以在右上⾓直接点击Add rule,来添加规则。

这⾥我们简单的做⼀个rewrite。

⽬标:当⽤户访问/aaa的话,⾃动访问到⽂件名为aaa.html的⽂件。

实现:点击Add rule,然后选择Blank rule,之后如图去填写规则:Name: 起⼀个名字,我们这⾥起名为”set aaa to aaa.html”Requested URL: 选择'匹配模式'(Matches the pattern)Using: 选择'精确匹配'(Exact Match) (如果你正则表达式(Regular Expressions)⾜够好的话,也可以⽤正则进⾏匹配) Pattern: 输⼊匹配的内容'aaa' (由于是精确匹配,所以我们只要输⼊精确匹配的内容即可)Action type: 选择rewrite。

Rewrite URL: 输⼊我们需要的aaa.html点击右上⾓的 Apply,保存即可。

IIS从7.0开始⽀持了这个URL Rewrite模块,⾥⾯不仅可以定义单个链接的重定向,还有整个⽬录的重定向,可以说功能强⼤,⽤起来⽅便。

⼗分推荐⼤家使⽤!。

IIS站点安装配置手册

IIS站点安装配置手册

铁血Web站点安装配置手册V1.02一.安装Web服务器1.系统要求Windows2008R2 X642.IIS要求IIS7.5 【必需】URL Rewrite 【可选】Application Request Routing 【可选】3.用户账号需求每台Web服务器均需要新建一个名为“pic”的用户,且所有该用户的密码一致,隶属于Users组,用户不能更改密码,密码永不过期。

【目前所有web服务器有该账号,便于管理】4.UNC权限需求【使用UNC路径时使用,不使用UNC跳过,默认跳过】备注:只有当使用集群的时候使用UNC路径,如122,124,125服务器和102,103服务器铁血未来站点均使用UNC目录进行配置,所以在站点文件提供服务器上需要共享一个目录,目前为\\192.168.0.122\WebNew,高级共享,权限为:◇1Users 【本地】◇2Domain Users 【域用户】◇3Administrators【本地】◇4Pic 【本地】以上用户需对共享目录有完全控制的权限在每台Web服务器上需要对站点文件存储的UNC共享目录配置完全信任关系,命令如下:○1C:\Windows\\Framework64\v2.0.50727\caspol.exe -rs [清除所有其它的信任]○2 C:\Windows\\Framework64\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\192.168.0.122\WebNew\*" FullTrust -exclusive on [添加IIS信任]5.IIS安装IIS7.5具体安装功能有:5.1 IIS安装(默认安装功能)◇1常见HTTP功能静态内容、默认文档、目录浏览、HTTP错误、HTTP重定向◇2应用程序开发 、.net扩展性、ISAPI扩展、ISAPI筛选器、在服务器端包含文件◇3健康和诊断HTTP日志记录、请求监视、自定义日志记录、ODBC日志记录◇4安全性基本身份验证、windows身份验证、请求筛选、IP和域限制◇5性能静态内容压缩动态内容压缩◇6管理工具IIS管理控制台5.2安装IIS URL Rewrite 2.0(可选)需要URL重写功能安装,即伪静态化时下载:URL Rewrite Module 2.0 X64/download/URLRewrite5.3 安装“网络负载平衡管理器”功能(可选)需要几台服务器做负载均衡时安装该组件系统自带,添加删除程序中5.4Frameworker2.0、Frameworker4.05.5 Application Request Routing(可选)当需要反向代理的时候需要安装下载Application Request Routing/download/ApplicationRequestRouting6.系统配置6.1 %WINDIR%\\Framework\v2.0.50727\aspnet.config中配置CONFIG<legacyUnhandledExceptionPolicy enabled="true" />6.2配置 MetaBase.xml gzip 相关 HcNoCompressionForHttp10="FALSE" HcNoCompressionForProxies="FALSE"6.3设置系统级别的MachineKey(可以直接从122上拷贝一份web.config直接覆盖)文件:C:\Windows\\Framework64\v2.0.50727\CONFIG\web.config位置:在该文件的</system.web>之前添加内容:<machineKey decryption="DES" decryptionKey="具体值" validationKey="具体值" />6.4关闭服务器的HTTPErr日志功能,必须关闭。

UrlRewrite安装手册

UrlRewrite安装手册

/news/docread.aspx?id=123
保在你移动网页后,那些被人收藏的老URL不会成为死链接。
眼即可看出你的网站是用什么语言做的。而且在改变网站的 的pagerank也会随之消失,从头开始。我们可以用UrlRewrite
网页的搜索相关性。具体来说,URL重写经常能使你在你网站上
3) 在 Web.Config的configuration结点中添加重写规则 注:1.请先备份好原来的配置文件,如果出现问题,还可恢复; 2.这里的重写规则需根据用户网站的需要添加,规则需有正则表达式知识的人员设置。
<rewriter> <rewrite url="^(/.+(\.gif|\.png|\.jpg|\.ico|\.pdf|\.css|\.js)(\?.+)?)$" to="$1" p <rewrite url="~/lmh$" to="~/Users.aspx?user=lmh" processing="stop" /> <rewrite url="~/tags/(.+)" to="~/tag/tagcloud.aspx?tag=$1" processing="stop"/> <rewrite url="^~/mypage(\?.+)?$" to="~/index.htm$1" processing="stop" /> <rewrite url="~/article-([^-]+)-([^-]+)-([^-]+).html" to="~/testurl/article. <rewrite url="^(.*)/(\?.+)?$" to="$1/index.htm$2?" /> </rewriter>

ISAP-rewrite

ISAP-rewrite

ISAPI_Rewrite是一个功能强大的网址操纵发动机的基础上正则表达式。

它的行为是像Apache的mod_Rewrite ,但专为微软的Internet信息服务( IIS )。

ISAPI_Rewrite是一个ISAPI筛选器的书面纯的C / C + +所以速度极快。

ISAPI_Rewrite让您的自由,超出标准网址计划和发展自己的计划。

第一。

首先到官方网站下载ISAPI_Rewrite我的机子是32位的就下32位免费版的,链接地址如下:/download/isapi_rewrite/ISAPI_Rewrite3_0064_Lite. msi可以选择不同版本:/download.asp第二:安装安装ISAPI_Rewrite3,一路next,默认安装到了服务器的C:\ISAPI_Rewrite3(目录自由设置,但需保证有iis浏览的权限),接着打开IIS-web服务扩张-右键-添加一个新的web服务扩展,扩展名字写ISAPI_Rewrite,要求文件C:\ISAPI_Rewrite3\ISAPI_Rewrite.dll,并且设置为允许。

配置IIS打开iis,右键你的站点属性--ISAPI 筛选器--添加--筛选器名称是ISAPI_Rewrite3 --可执行文件就是ISAPI_Rewrite.dll的路径,比如C:\ISAPI_Rewrite3\ISAPI_Rewrite.dll 给用户网站主机头加上“network service”的读权限,其实就是该用户网站的文件夹的网络读写权限。

安装IIS Rewrite3后,会在全局的网站下“iis> 网站》属性> isapi 筛选器”选项里面,删除 isapi_rewrite3这个ISAPI筛选器,必须去掉这个isapi_rewrite3筛选器,否则其它的网站(除首页外)的页面无法访问!最后重启iis当然你可以把ISAPI_Rewrite3目录放入站点根目录下,但记得要给一个users和"network service"的读权限。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

URL REWRITE,我的翻译是URL重写,或者URL重定义。在asp+iis的网站开发模式中,
可以实现如将http://xxxxxx.cn/news.asp?id=220 变成http://xxxxxx.cn/220.html 的
形式。例如某条新闻的实际网址是http://xxxxxx.cn/news.asp?id=220 ,通过URL重写之
后,我们就可以直接输入 http://xxxxxx.cn/220.html 的网址,来访问该条新闻。

对于iis服务器,要实现此项功能,需从 http://www.helicontech.com/download/ 网站上,
下载Lite Version (free)免费版的软件,将此软件安装于服务器之后,在其安装目录上,找到
配置文件httpd.ini,用记事本打开,输入相应的规则。然后,在相应的站点上,ISAPI中,添加
此组件。OK,配置完成,功能生效。

2、URL_REWRITE的规则写法参考:
当我需要将将news.asp?id=234的映射成news/234.html时,只需设置:
RewriteRule /news/(\d+)\.html /news\.asp\?id=$1 [N,I]
这样就把 /news/234.html 这样的请求映射成了 /news.asp?id=234
当有对/news/234.html的请求时:web服务器会把实际请求转发给/news.asp?id=234

比对于某一个简单应用可以是:
RewriteRule /news/(\d+)\.html /news/news\.php\?id=$1 [N,I]
这样就把 http://www.xxxxxx.com/news/234.html 映射到了 http://www.xxxxxx.co
m/news/news.php?id=234

一个更通用的能够将所有的动态页面进行参数映射的表达式是:
把 http://www.xxxxxx.cn/foo.php?a=A&b=B&c=C
表现成 http://www.xxxxxx.cn/foo.php/a/A/b/B/c/C

RewriteRule (.*?\.php)(\?[^/]*)?/([^/]*)/([^/]*)(.+?)? $1(?2$2&:\?)$3=$4?5$5: [N,I]
3、使用URL重写功能的好处:
首先,有助于增加网站的安全性,因为它隐藏了诸如asp php jsp等相关的服务器技术,以最
原始的html文件形式,呈现于客户。

其次,在平台移植时,不会各页面的网站。如将news.asp?id=123转移news.php?id=123,
即将asp平台转移php,如使用此URL重写,这个页面的网址就是news/123.html。

其它方面,方便URL引用,有助于搜索引擎的枚举。
ISAPI_rewrite中文手册
http://www.isapirewrite.cn/docs/

其他相关URL重写扩展产品
ABC_Rewrite
http://www.jrsw.com/iis/index.html

紫雨轩IIS URL 重写组件
http://www.redcheek.net/blogview.asp?logID=110

相关文档
最新文档