Simple IIS URL Rewrite needed

Hello,

I need to create a simple IIS URL Rewrite rule that does the following:

If user accesses http (or https)://folder1/filea.asp

Redirect user to: http (or https)://folder2/filea.asp

Thanks in advance,

Steve
skbohlerAsked:
Who is Participating?
 
Ryan ChongConnect With a Mentor Commented:
>>a specific file
do you mean filea.asp?

if you only required http (or https)://folder1/filea.asp to be redirected to http (or https)://folder2/filea.asp

then you can try a fixed rule:

<rule name="RewriteUserFriendlyURL" enabled="true" stopProcessing="true">
                    <match url="folder1/filea.asp" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Redirect" url="folder2/filea.asp" appendQueryString="false" />
                </rule>

Open in new window

0
 
Olivier MARCHETTASystems EngineerCommented:
Hello. You can install the IIS rewrite module from this page :
https://www.iis.net/downloads/microsoft/url-rewrite

Then you can use this guide :
https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

1. Create a default website
2. Open the URL Rewrite module in the webpage configuration panel
3. Create a blank rule
4. Enter the pattern or the expression you want to rewrite.
0
 
Ryan ChongCommented:
try and see if this work for you in http / https?

(tested working in http)

<rule name="RewriteUserFriendlyURL" enabled="true" stopProcessing="true">
                    <match url="^folder1/([^/]+)/?$" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Redirect" url="folder2/{R:1}" appendQueryString="false" />
                </rule>

Open in new window

1
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
skbohlerAuthor Commented:
Hi Ryan,
Thanks for the reply.

Does that rule work for both http and https?

I have a finite list of URLs that I need to redirect from one directory to another. So, I believe I the matchURL should be something more specific than <match url="^folder1/([^/]+)/?$" />, no?

Wouldn't that rule apply to all files in folder1?
0
 
Ryan ChongCommented:
Does that rule work for both http and https?
you probably can try it out, as I don't have a https site for testing. it should worked for both http and https.

Wouldn't that rule apply to all files in folder1?
yes
0
 
Ryan ChongCommented:
any further clarification is needed here?
0
 
skbohlerAuthor Commented:
I needed a versions that works for a specific file in a specific directory. Not all files in a specific directory. How can I achieve that?

Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.