URL rewrite to only match on top level folder

I use windows 2008 server with IIS7 and have created the following URL rewrite rule:

<rule name="Rewrite english to /index.asp">
      <match url="english" />
      <action type="Rewrite" url="index.asp" />
 </rule>

Open in new window


What this does is when the URL is written as:

www.mywebsite.com/english

It would redirect to:

www.mywebsite.com/index.asp

The only problem is that if there are any files on the website which start with the text "english" then the rule would apply to that filename. I have an image called english-rose.jpg which would not display when this rule was in place. As soon as I removed the rule it was fine.

So what I want is to change the rule so it only matches on /english and no other variation.
mike99cAsked:
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.

Dan McFaddenSystems EngineerCommented:
Try this:

<rule name="Rewrite english to /index.asp">
      <match url="english/" />
      <action type="Rewrite" url="index.asp" />
 </rule>

Open in new window


Dan
0
mike99cAuthor Commented:
Thanks Dan. While this has solved the issue of the image now being recognised, the problem I have now is that the URL only works with the forward slash in front like so:
www.mywebsite.com/english/

But I would still like it to work as before:
www.mywebsite.com/english
0
NerdsOfTechTechnology ScientistCommented:
try:
<match url="english(\/)?$">

Open in new window


MATCHES:
english/
english

BUT DOES NOT MATCH:
english-rose.jpg
english.php
english.html
english/1
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.

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.