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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Olivier MARCHETTACitrix Support and Infrastructure 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.
Ryan ChongSoftware Team LeadCommented:
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

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?
CEOs need to know what they should worry about

Nearly every week during the past few years has featured a headline about the latest data breach, malware attack, ransomware demand, or unrecoverable corporate data loss. Those stories are frequently followed by news that the CEOs at those companies were forced to resign.

Ryan ChongSoftware Team LeadCommented:
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
Ryan ChongSoftware Team LeadCommented:
any further clarification is needed here?
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.
Ryan ChongSoftware Team LeadCommented:
>>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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.