iis7.5 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。

解决iis7.5服务器上.net 获取不到https页面的信息

解决iis7.5服务器上.net 获取不到https页面的信息

我的获取页面需要cookie,不需要的可以去掉;GET的方法:代码如下:/// &lt;summary&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// 获取URL访问的HTML内容获取https 页面的&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;param name="Url"&gt;URL地址&lt;/param&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;returns&gt;HTML内容&lt;/returns&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static string GetWebContent(string Url, CookieContainer cookieContainer)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string strResult = "";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; ServicePointManager.Expect100Continue = true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; request.CookieContainer = cookieContainer;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; request.Timeout = 30000;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; request.Headers.Set("Pragma", "no-cache");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; HttpWebResponse response = (HttpWebResponse)request.GetResponse();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; Stream streamReceive = response.GetResponseStream();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; Encoding encoding = Encoding.GetEncoding("utf-8");&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; StreamReader streamReader = new StreamReader(streamReceive, encoding);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; strResult = streamReader.ReadToEnd();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return strResult;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;POST的方法:代码如下:/// &lt;summary&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// post提交数据到https&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;/summary&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;param name="posturl"&gt;&lt;/param&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;param name="postdata"&gt;&lt;/param&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;param name="header"&gt;&lt;/param&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;param name="cookieContainer"&gt;&lt;/param&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /// &lt;returns&gt;&lt;/returns&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static string SetPostHtml(string posturl, string postdata, HttpHeader header, CookieContainer cookieContainer) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string restr = "";&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServicePointManager.Expect100Continue = true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpWebRequest request = null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpWebResponse response = null;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request =(HttpWebRequest)WebRequest.Create(posturl);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.CookieContainer = cookieContainer;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.Method = header.method;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.Referer = header.Referer;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.ContentType = header.contentType;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] postdatabyte = Encoding.UTF8.GetBytes(postdata);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.ContentLength = postdatabyte.Length;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.AllowAutoRedirect = false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; request.KeepAlive = true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //提交请求&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Stream stream;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream = request.GetRequestStream();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream.Write(postdatabyte, 0, postdatabyte.Length);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stream.Close();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //接收响应&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; response = (HttpWebResponse)request.GetResponse();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; using (StreamReader reader = new StreamReader(response.GetResponseStream()))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp; restr = reader.ReadToEnd().ToString();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return restr;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }更多信息请查看IT技术专栏。

windows rewrite url 规则

windows rewrite url 规则

windows rewrite url 规则
Windows中的URL重写规则是通过IIS(Internet Information Services)来实现的。

IIS是Windows中用于托管和管理Web 应用程序的服务器软件。

要在Windows上设置URL重写规则,可以按照以下步骤进行操作:
1. 打开IIS管理器。

可以通过在开始菜单中搜索“IIS管理器”或者在控制面板中找到“管理工具”下的“Internet Information Services(IIS)管理器”来打开。

2. 在IIS管理器中,选择要设置URL重写规则的网站或应用程序。

3. 在右侧的“特性视图”中,双击“URL重写”,打开URL重写规则的设置。

4. 在URL重写规则窗口中,可以点击“添加规则”来添加新的URL重写规则。

5. 在添加规则窗口中,可以设置规则的名称、匹配模式、条件和操作。

- 名称:为规则设置一个名称,用于标识和管理规则。

- 匹配模式:设置一个正则表达式或者其他匹配模式,用于匹配输入的URL。

- 条件:可选设置,用于进一步限制规则的应用范围。

- 操作:指定重写的URL或执行其他操作,如重定向或中止请求。

6. 完成设置后,点击“应用”按钮保存规则。

可以根据具体的需求和业务逻辑设置不同的URL重写规则,以实现URL的重定向、路径的重写和请求的转发等操作。

URL重写规则可以通过指定的匹配模式来匹配URL,并根据条件和操作执行相应的处理。

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日志功能,必须关闭。

iis urlrewrite 参数转路径的配置方法

iis urlrewrite 参数转路径的配置方法

iis urlrewrite 参数转路径的配置方法IIS(Internet Information Services)中的URLRewrite模块是一种强大的工具,可用于对网站中的URL进行转换和重写。

它可以帮助我们轻松地处理各种URL规则,并提供了一种灵活的方式来重定向请求、修改URL结构或实现其他与URL相关的操作。

在本文中,我们将介绍如何使用URLRewrite模块参数转路径的配置方法。

一、了解URLRewrite模块URLRewrite模块是IIS中的一项功能,它允许管理员定义一系列规则来处理进入和离开网站的请求。

这些规则可以根据URL的结构、内容或参数进行匹配和转换。

通过使用URLRewrite模块,我们可以轻松地实现诸如隐藏原始应用程序目录、实现路由转换或重定向到其他页面等任务。

二、配置参数转路径规则要配置参数转路径规则,您需要按照以下步骤进行操作:1. 打开IIS管理控制台,导航到您要配置的网站。

2. 在网站上展开“URL重写”选项,然后选择“URL重写规则列表”。

3. 右键单击空白区域,选择“新建重写规则”。

4. 在“新建重写规则”对话框中,输入一个新的重写规则的名称和描述。

5. 在“匹配模式”选项卡中,选择适当的匹配类型(如正则表达式)并编写匹配规则。

您可以使用通配符、变量和条件语句来定义匹配模式。

6. 在“重写结果”选项卡中,指定要应用于匹配请求的新的URL 路径。

您可以使用变量、参数和条件语句来定义新的路径。

7. 完成规则配置后,点击“确定”保存规则。

三、使用变量和参数在URLRewrite模块中,您可以使用变量和参数来传递原始请求中的值到新的路径中。

这使得您可以轻松地处理动态内容或根据用户输入生成新的URL路径。

* 变量:变量是用于存储原始请求中的值的占位符。

您可以在匹配模式中使用变量名称来引用它们。

在重写结果中,您可以指定将变量替换为新的值或将其保留不变。

* 参数:参数是用于从原始请求中提取特定值的方法。

iis配置重写规则

iis配置重写规则

iis配置重写规则IIS配置重写规则IIS(Internet Information Services)是微软公司开发的一款web 服务器软件,用于托管和管理网站。

在IIS中,配置重写规则是一项非常重要的功能,它可以帮助我们实现URL重写、重定向、路径映射等功能,从而提升网站的用户体验和SEO优化效果。

配置重写规则的作用是将传入的URL进行处理,并根据事先设定的规则进行转换。

在IIS中,我们可以使用Web.config文件或者IIS 管理工具来配置重写规则。

我们需要在Web.config文件中添加一个<system.webServer>节点,然后在<system.webServer>节点下添加一个<rewrite>节点,用于配置重写规则。

在<rewrite>节点下,我们可以添加多个<rule>节点,每个节点代表一条重写规则。

例如,我们可以通过以下的配置将所有的URL重写到一个默认的页面上:<system.webServer><rewrite><rules><rule name="Rewrite to default page"><match url=".*" /><action type="Rewrite" url="default.aspx" /></rule></rules></rewrite></system.webServer>在上述的配置中,<match>节点用于指定匹配的URL模式,这里使用了".*"表示匹配任意字符。

<action>节点用于指定重写的动作,这里使用了"Rewrite"表示重写到指定的URL。

IIS(Internet Information Services)7.5常见问题

IIS(Internet Information Services)7.5常见问题

IIS升级到7.5后原来的WebService出现的两个问题
最近换了个笔记本电脑,系统从XP SP3变为Win 7,IIS版本也变为7.5。

但是原来演示用V S2008来创建Web Service的程序不工作了,在调用Web Service时出现了2个问题。

1. 出现500.19 Error 。

错误提示:
不能在此路径中使用此配置节。

如果在父级别上锁定了该节,便会出现这种情况。

锁定是默认设置的(overrideModeDefault="Deny"),或者是通过包含overrideMode="Deny" 或旧有的allowOverride="false" 的位置标记明确设置的。

发现是在安装IIS时没有安装。

见下图:
2. 而后又出现以下配置错误:
在应用程序级别之外使用注册为allowDefinition='MachineToApplication' 的节是错误的。

如果在IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误。

发现是在IIS中没有将虚拟路径配置为应用程序。

这时应将虚拟路径转换为应用程序,见下图:
解决了这两个问题,原来的Web Service又工作了。

urlrewrite使用

urlrewrite使用

urlrewrite使用URLRewrite(URL 重写)是一种服务器端技术,用于修改请求的 URL 地址,以便更好地满足网站的需求。

它可以将一个复杂或不易理解的 URL 转换为更简单、更易读或更有意义的 URL。

以下是使用 URLRewrite 的一般步骤:1. 配置 IIS(Internet Information Services):如果你使用的是 IIS 作为 Web 服务器,你需要在 IIS 管理器中配置 URLRewrite。

打开 IIS 管理器,选择你的网站,然后双击 "URLRewrite" 图标。

2. 创建规则:在 URLRewrite 界面中,你可以创建新的规则或编辑现有的规则。

点击"Add Rule" 或 "Edit Rule" 按钮。

3. 定义规则条件:在规则编辑界面中,你可以定义规则的条件。

这些条件可以基于请求的 URL、请求方法、服务器变量等。

你可以使用正则表达式来匹配特定的模式。

4. 设置重写行为:一旦规则的条件被满足,你可以设置重写行为。

这包括将请求重定向到另一个 URL、修改 URL 参数、替换 URL 部分等。

5. 测试和启用规则:在完成规则的定义后,你可以进行测试以确保规则按预期工作。

点击 "Test" 按钮来测试规则。

如果规则测试成功,你可以启用规则。

需要注意的是,URLRewrite 的具体配置和使用方法可能因所使用的 Web 服务器和URLRewrite 模块而有所不同。

以上步骤提供了一般的指导,你需要根据你的具体环境和需求进行相应的调整。

如果你在使用 URLRewrite 时遇到问题,建议参考相关的文档、教程或向技术支持人员寻求帮助。

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

首先说的是IIS7.5,win7或者win2008都支持,然后要下载一个微软的组件:Url重写组件,这里发个64位的组件,如果你的系统是32位的可以网上找下,很多的。

64位URL重写组件:/share/link?shareid=149304&uk=991867769
安装好后,打开你的IIS就会有如图所示的图标:
URL重写
然后打开你要设置的网站,右侧就会有如图所示:
url重写
这里学习吧提供几种方案:
1,URL域名规模化;
比如你想让你的的一访问就访问到www。

xx。

com上,这样对用户和搜索都好的,也不会让百度重复收录你的网站。

点击右击的“添加规则”,然后选择规范域名
然后在出现的窗口里选择你的域名,有人说为什么我这没有多个域名呢?那是因为你没有绑定多个域名!
URL重写
点击确认即可,学习吧说明:iis7.5都是操作的web.config里的代码来达到各种设置的!设置域名规范化必须你的主域名和要转向的域名都解析到你的服务器上,并且成功把域名绑定到站点上才能生效!
2,伪静态
在IIS6.0在时代都是设置的httd.ini,而在iis7.5里得设置web.config了。

如果你有.htaccess现成文件,那么可以通过导入规则直接使用!
点击右侧的“入站规则”里的“导入规则”,然后出现如图:
URL重写
配置文件里选择你要导入的文件路径,选择后点击导入按钮,如果你的文件格式正确那么就
会成功导入规则!直接应用即可!
如果没有配置文件,那么自己就动手写下吧.
点击右侧“添加规则”,然后选择“空白规则”,出现添加规则窗口:
名称自己起个就行,然后“匹配URL”里基本可以默认,只需要自己填写上“模式”即可,这里是正则表达式,比如:^(\w+)_xieliang_(\d+)$ 这其中的^是开始,$表示结束,(\w+)表示字母,数字任意,(\d+)表示只能为数字,(.*)为所有,更多正则请看:正则表达式
然后下面的重写URL写成动态的URL,并且要带参数,比如show.asp?url={R:1}&id={R:2}其中的{R:1}就是正则里的前面的变量,一共有几个参数要与正则里对应!
URL重写
3,防盗链
防盗链的原理是根据来路判断是否为自己的域名,如果不是则终止
步骤和伪静态一样,只是正则为^(.*)\.(gif|jpg)$这个是所有的gif jpg后缀的,根据自己的情况设置
添加几个条件,因为要判断来路
URL重写
其中第一个条件是为了查看是否为自己的来路
第二个为判断是否有来路,如果直接打开的就没有来路,如果想让用户直接打开不能用,只有从自己网站打开才可以的话要加上这个,如果不用可以去掉!
在最下面操作里的重写URL填上如果拦截要显示的图片路径即可。

学习吧提示:也可以根据防盗链自己写个防下载的哦,只是后缀不一样罢了。

URL重写。

相关文档
最新文档