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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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
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
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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 ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
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
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
>>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

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.