开发者

IIS redirect for files that have changed paths

The original URL: http://www.example.com/articles/articles/filename.pdf

and others in开发者_StackOverflow社区 that directory are now at: http://www.example.com/articles/filename.pdf

IIS redirect for files that have changed paths

IIS redirect for files that have changed paths

IIS redirect for files that have changed paths

We have lots of old links we don't control, however, that point to the first URL. I have a shared IIS 7 account that has an enabled "URL Rewrite" However, I am having difficulty with the actual implmentation. For example, I'm using this matching pattern:

http://www.example.com/articles/articles/(.*)$ and, according to the test dialog, it catches every instance of file in that directory. On the other end, I've specified a Redirect action, where the redirect URL pattern is: http://www.example.com/articles/{R:1}. That seems like that should do it. I apply my changes, restart the app pool and... nothing happens when I enter the first URL.

TIA!


With big thanks to jcolebrand's input, I got this untangled:

To do what I needed, there are three fundamental steps to this process:

  1. Create an inbound rule where the pattern matched is essentially any web request
  2. The "Condition" lets me specify which URL paths to act on
  3. The "Action" pane lets me do the redirect

I had been skipping step #2, so I was not passing any usable information to step #3. Going forward, here's what I did:

  1. Create a new, blank inbound rule
  2. The "Requested URL" pattern will match any URL submitted
  3. Add a condition:
  4. Condition Input: {PATH_INFO}
  5. Check if input string "Matches the Pattern"
  6. Pattern: ^/(articles|technical)/articles/(.*)$
  7. Use the "Test pattern…" to confirm that the pattern works as expected. I also use the Test Results: Capture Groups for the backreference information.
  8. Under "Action" specify" Redirect, with the redirect URL being "/articles/{C:2}"
  9. Redirect type: Permanent (301) which helps google regarding site indexing as well

I did not have to restart the app pool after making the above changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜