简体   繁体   中英

IIS URL Rewrite: Redirect not working?

I am trying to write a simple 301 redirect using the URL rewrite module. I have set the rule up using the interface in IIS 7.5. Unfortunately none of the rules I have added are actually working and I don't understand why.

  1. I provide a name for the rule
  2. I select Matches the Pattern under Requested URL:
  3. I select Exact Match
  4. I enter the pattern http://www.example.com/folder/page.htm
  5. I check Ignore case
  6. Under action I specify Action type as Redirect
  7. I set the redirect URL as http://www.example.com/folder
  8. I check the Append query string
  9. I select permanent 301 under redirect type

As far as I can tell this means a request to http://www.example.com/folder/page.htm should redirect to http://www.example.com/folder

However I end up with 404 errors instead?

I have tried to find a simple example online but most of the ones I see are using regular expressions which I don't think I need. I also tried a wildcards and */folder/page.htm but this also gives me the same problem.

What am I doing wrong?

Ok for anyone else who has this problem it appears you do not need to have the domain in the URL because this will cause the pattern not to match.

So in my case for step 4 I should enter folder/page.htm (not /folder/page.htm either!)

Now the redirect works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM