Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS rewrite virtual folder

Tags:

url

iis

rewrite

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

From:

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

To:

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

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

like image 456
Technomorph Avatar asked May 15 '13 09:05

Technomorph


1 Answers

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>

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.

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

like image 105
cheesemacfly Avatar answered Oct 20 '22 08:10

cheesemacfly