我有Windows Server 2012,我已经安装了IIS 8.5,但我看不到URL重写模块.我该如何启用或安装?
随着Windows 8.1最终发布到MSDN/Technet,我在使用Win 8.1 RTM进行就地升级后遇到了运行我的ASP.NET应用程序的以下问题:
暂停服务
http错误503服务不可用.
StoppedWindows应用程序日志中有一条线索,其中包含此错误
The Module DLL C:\WINDOWS\system32\inetsrv\rewrite.dll failed to load. The data is the error.
如何恢复我的IIS以使其再次工作?
我正在尝试从表单中重写网址:
https://example.com/about
Run Code Online (Sandbox Code Playgroud)
到形式
http://example.com/about
Run Code Online (Sandbox Code Playgroud)
使用IIS7 URL重写:
<!-- http:// to https:// rule -->
<rule name="ForceHttpsBilling" stopProcessing="true">
<match url="(.*)billing/(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="false" />
</conditions>
<action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
<!-- https:// to http:// rule -->
<rule name="ForceNonHttps" stopProcessing="true">
<match url="(.*)billing/(.*)" ignoreCase="true" negate="true" />
<conditions>
<add input="{SERVER_PORT}" pattern="^443$" />
</conditions>
<action type="Redirect" redirectType="Found" url="http://{HTTP_HOST}{REQUEST_URI}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
我不知所措; 我一直在浏览网页上的例子,并尝试我能想到的每一种语法.我简单地指定重写规则似乎没有工作,在所有的任何HTTPS请求,就好像所有的https://请求都平了无形的重写引擎.
规则工作正常; 见下面的答案.
我正在使用IIS7 UrlRewrite模块.我在web.config <system.webServer><rewrite>部分设置了规则.我想知道是否有一种方法可以在一个外部xml文件而不是web.config文件中定义规则.谢谢.
我在根据查询字符串参数重定向到另一个URL时遇到一些问题.我想将输入www.domain.com/signup.aspx?p=1的用户重定向到:
www.domain.com/signup
<rule name="Signup Redirect 1" stopProcessing="true">
<match url="signup\.aspx\?p=1" />
<conditions logicalGrouping="MatchAll" />
<action type="Redirect" url="signup" redirectType="Temporary" />
</rule>
Run Code Online (Sandbox Code Playgroud)
现在,当他们进入www.domain.com/signup.aspx?p=2时,他们必须去:
www.domain.com/signup/promocode
<rule name="Signup Redirect 2" stopProcessing="true">
<match url="signup\.aspx\?p=2" />
<conditions logicalGrouping="MatchAll" />
<action type="Redirect" url="signup/promocode" redirectType="Temporary" />
</rule>
Run Code Online (Sandbox Code Playgroud)
以上规则不起作用.这样做的正确方法是什么?提前致谢.
GR
马亭
我正在尝试使用Rewrite Module 2.0进行URL 重写,但我没有运气让它工作.我要做的是将端口80上的所有对Web应用程序的调用重新写入IIS中托管的其他应用程序(或者可能在网络上的不同服务器上).使用IIS提供的GUI我创建了以下规则:
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="site1/(.*)" />
<action type="Rewrite" url="http://localhost:7001/{R:1}" />
</rule>
</rules>
</rewrite>
Run Code Online (Sandbox Code Playgroud)
安静简单,但不幸的是它不起作用.另一方面,当我将动作类型更改为时Redirect,它可以正常工作.
可能是什么问题呢?
通过IIS URL重写模块向所有URL添加尾部斜杠广泛传播,但如何为以.html和.aspx结尾的URL添加例外?
今天我有这个:
<rule name="Add trailing slash" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<!-- Doesn't seem to be working -->
<!--<add input="{REQUEST_URI}" pattern="(.*?).html$" negate="true" />-->
<!--<add input="{REQUEST_URI}" pattern="(.*?).aspx$" negate="true" />-->
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}/" />
</rule>
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置IIS URL重写规则以匹配403响应,因为有人在禁用目录浏览时尝试浏览目录.我想然后将它们重定向到我为404定义的通常的ASP.NET自定义错误页面.
这就是我目前所拥有的:
<outboundRules>
<!-- By default, browsing a directory with no default resource will return 403 -->
<rule name="Directory browsing location">
<match serverVariable="RESPONSE_LOCATION" pattern="(.*)" />
<conditions>
<add input="{RESPONSE_STATUS}" pattern="^403" />
</conditions>
<action type="Rewrite" value="/Error/PageNotFound?aspxerrorpath={PATH_INFO}"/>
</rule>
<rule name="Directory browsing status code" patternSyntax="ExactMatch">
<match serverVariable="RESPONSE_STATUS" pattern="403" />
<action type="Rewrite" value="302" />
</rule>
</outboundRules>
Run Code Online (Sandbox Code Playgroud)
我的假设是它需要是一个出站规则,我需要重写状态代码并添加位置响应头,尽管后者在最初的403响应中不会存在.
目前的行为是......没有.无论我做多少调整,我仍然会看到403s.有什么想法吗?
顺便说一下,不,网站上没有任何合法的403可以被吞下.我还可以为可能导致满足条件的每个路径创建入站规则,但这不是很可扩展.
每当有人通过HTTP协议发出请求时,我都会重写url以使其成为HTTPS.这是web.config中的代码:
<rule name="Imported Rule 1-1" enabled="true" stopProcessing="true">
<match url="^(?!https://).*" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{SERVER_PORT}" pattern="80" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="https://abc.com/{R:1}" />
</rule>
Run Code Online (Sandbox Code Playgroud)
但是,当我在http://上浏览时,我收到IIS错误
HTTP错误500.50 - URL重写模块错误.表达式
"https://abc.com/{R:1}"无法扩展.
我该如何解决这个问题?我完全糊涂了.
我的生产设置如下:
使用IIS URL Rewrite,对M2的任何请求,例如http:// m2 /app/login.aspx将被重定向到M1,如http:// m1 /app/login.aspx.
在M1上,ASP.NET Open Auth已在网站上实施,以使用Google外部身份验证.当用户点击Google按钮时,浏览器将被重定向到Google登录页面以允许用户进行身份验证.
但是当从M2访问网站时,.net oAuth(https:// accounts.google.com/[query-string])生成的重定向网址将重定向到Google,正在被URL重写替换为http:// m2/[query-string].
所以要清楚; 当通过外部身份验证提供程序进行身份验证请求时,将返回302重定向.通常这种形式可能如下所示:
响应标题:
...
位置:https:// accounts.google.com/o/oauth2/auth?big_long_query_string
...
此重定向由位于代理服务器后面的服务器(M1)创建(M2 - IIS URL Rewrite 2.0 + ARR 3.0).因此,重写服务器将Location标头重写为:
响应标题:
...
位置:http:// M1/o/oauth2/auth?big_long_query_string
...
我们需要的是一条规则,它不会在重定向时重写位置URL.它也只能针对某些重定向.大多数情况下,这里提到的行为是必需的,因为所有重定向都被重定向到主代理服务器.有人可以为某些重定向建议解决方案或解决方法吗?
asp.net ×5
iis ×5
iis-7 ×4
web-config ×2
.net ×1
arr ×1
https ×1
iis-8.5 ×1
oauth ×1
windows-8.1 ×1