IIS重写虚拟文件夹 [英] IIS rewrite virtual folder

查看:109
本文介绍了IIS重写虚拟文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在IIS中为以下内容创建URL重写规则:

I need to create a URL rewrite rule in IIS for the following:

来自:

http://hostname/virtual_path_folder/myisapi.dll?a=1&b=1

收件人:

http://hostname/myisapi.dll?a=1&b=1

基本上,如果可能的话,我只想隐藏virtual_path文件夹。

Basically, I'd just like to hide the virtual_path folder if possible.

推荐答案

您可以遵循以下两条规则:

You could go with the 2 following rules:

<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>

第一个,重定向,如果virtual_path_folder ,将重定向以 virtual_path_folder / 开头的每个请求。它会阻止任何人使用子文件夹访问您的内容。

The first one, Redirect if virtual_path_folder, will redirect every request starting with virtual_path_folder/. It will prevent anyone from accessing your content using the sub folder.

第二个重写任何请求( ^。* $ )到子文件夹: virtual_path_folder / {R:0}

The second one rewrites any request (^.*$) to the sub folder: virtual_path_folder/{R:0}

这篇关于IIS重写虚拟文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆