Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 793
David Hirst Avatar asked Oct 18 '25 11:10

David Hirst


1 Answers

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.

like image 88
David Hirst Avatar answered Oct 22 '25 06:10

David Hirst



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!