Asp.net Web.Config IIS重写规则
我有一个将所有请求重定向到index.php的站点。但是,我需要对我的web.config稍作更改 这是重定向部分中当前的内容:Asp.net Web.Config IIS重写规则,asp.net,iis,web-config,Asp.net,Iis,Web Config,我有一个将所有请求重定向到index.php的站点。但是,我需要对我的web.config稍作更改 这是重定向部分中当前的内容: <rewrite> <rules> <rule name="Process" stopProcessing="true"> <match url=".*" /> <conditions> <add i
<rewrite>
<rules>
<rule name="Process" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
但是,我需要它,这样如果有人转到/news,它就会转到news.php
,而不是index.php
我会使用什么规则?我会把它放在哪里?我来自Apache背景,但我的客户端正在使用IIS。您可以在现有的上插入另一条规则,只需进行一些更改即可重定向到您的位置 这也可以在IIS管理器中完成。这样做将允许您测试所使用的语法,以查看它是否适用于所需的URL
<rule name="Rewrite-News" patternSyntax="ExactMatch" stopProcessing="true">
<match url="news" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="news.php" appendQueryString="false" />
</rule>
所以看起来有点像这样:
<rewrite>
<rules>
<rule name="Rewrite-News" stopProcessing="true">
<match url="news" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="news.php" appendQueryString="false" />
</rule>
<rule name="Process" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>