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
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:
- Create an inbound rule where the pattern matched is essentially any web request
- The "Condition" lets me specify which URL paths to act on
- 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:
- Create a new, blank inbound rule
- The "Requested URL" pattern will match any URL submitted
- Add a condition:
- Condition Input: {PATH_INFO}
- Check if input string "Matches the Pattern"
- Pattern: ^/(articles|technical)/articles/(.*)$
- Use the "Test pattern…" to confirm that the pattern works as expected. I also use the Test Results: Capture Groups for the backreference information.
- Under "Action" specify" Redirect, with the redirect URL being "/articles/{C:2}"
- 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.
精彩评论