Cannot 301 redirect with IIS URL Rewrite Module

301-redirectiis-7redirectrewrite

I am trying to troubleshoot my issue with the URL Rewrite Module on IIS 7.

I migrated a WordPress blog over to BlogEngine.net. There were only about 5 entries that I wanted to use 301 redirects to the new blog, so I wanted to simply create 5 exact match redirect rules using the rewrite module. For some reason the exact match rule never seems to take effect, I always get a 404 error when the original url is navigated to.

I verified that my exact match pattern matched the existing backlinks and it does. I then tried a simple test and got the same behavior, no redirection. I created a page, test.html, on my site, I then created a second page, test2.html. So my exact match pattern is:

"http://www.mydomain.com/test.html"

And the rule is supposed to do a 301 redirect to "http://www.mydomain.com/test2.html
"
The redirect never happens.

I created the steps for the rule based on the instructions in this page:
http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/

I don't see that I left out a step. After I apply the rule I've even gone as far as doing an IISReset to make sure it would be in effect but still no luck.

Any thoughts on what I might have left out?

(Note: my rewrite rules dont include the " " around them but I had to add since serverfault thinks I am trying to spam the system with multiple urls.)

Best Answer

The patterns are relative to the root of the site, not including the domain name, so in this case, the pattern should be:

^test\.html

This will match http://example.com/test.html and then apply the rules you have set for it.

Related Topic