我需要在IIS中创建一个URL重写规则如下:IIS重写虚拟文件夹
来源:
http://hostname/virtual_path_folder/myisapi.dll?a=1&b=1
要:
http://hostname/myisapi.dll?a=1&b=1
基本上,我只是想如果可能的话隐藏virtual_path文件夹。
我需要在IIS中创建一个URL重写规则如下:IIS重写虚拟文件夹
来源:
http://hostname/virtual_path_folder/myisapi.dll?a=1&b=1
要:
http://hostname/myisapi.dll?a=1&b=1
基本上,我只是想如果可能的话隐藏virtual_path文件夹。
你可以用2条以下规则去:
<rules>
<rule name="Redirect if virtual_path_folder" stopProcessing="true">
<match url="^virtual_path_folder/(.*)$" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="Rewrite to sub folder">
<match url="^.*$" />
<action type="Rewrite" url="virtual_path_folder/{R:0}" />
</rule>
</rules>
第一个,Redirect if virtual_path_folder
,将重定向开始virtual_path_folder/
每个请求。它会阻止任何人使用子文件夹访问您的内容。
第二个重写任何请求(^.*$
)到子文件夹:virtual_path_folder/{R:0}
谢谢你完美的作品。 – Technomorph
@cheesemacfly我有一个类似的问题来解决。您的解决方案效果很好,但如果我有一个virtual_path_folder_B和virtual_path_folder_C,该规则不能应用?我尝试添加'
@ MaxS-Betclic如果请求的url是http:// yourwebsite.com/virtual_path_folder_C'并且显示'virtual_path_folder_C'的内容,您希望避免使用'Rewrite'? – cheesemacfly
我曾尝试数次以得到这个工作 - 我我只是不能这样做呢?
我没有收到错误 - 但它不会从URL中删除ices328w10?
的网址是: http://chrissgaraglino.com/icws328w10/index.cfm
这里是我的,而文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect if icws328w10" stopProcessing="false">
<match url="^icws328w10/(.*)$" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="LowerCaseRule1" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" pattern="(.*?)\.css$" negate="true" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
这或许是可能的。你使用什么IIs版本? – cheesemacfly
嗨。 7.5。谢谢 – Technomorph
你需要这个规则才适用于'myisapi.dll?a = 1&b = 1'的请求?或任何网址? – cheesemacfly