Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Windows 2008 Server: IIS 7.5
I want to construct a rewrite and redirect rule so that if it fails, (can't find the page because the condition is not met, or perhaps page does not exist) another rule is activated that redirects the user to a custom 'explanation' page (not a general 404 error page).

I have a redirect rule in place now that adequately redirects the user from a PDF file located on the old server (old domain/URL) to a PDF file with the same name on the new server (with new domain/URL but same folder structure). However, if the requested PDF file is not found on the old server a 404 error from the new server displays 'Not Found'. I would like instead for all pdf files not found under the /assets/pdfs/ folder on the old server to display a custom 'Help' page preferably located on the new server.

<rule name="ABC resources redirect" enabled="true" stopProcessing="true">
    <match url="^~abc/assets/(.*)" ignoreCase="true" />   
    <action type="Redirect" url="http://mainsite.org/abc/assets/{R:1}" />  
</rule>

I have tried a another rule which does this 2nd action but it is an either or situation. Even with both enabled it stops after the first (above) rule. If I switch them the 2nd rule (below) runs. This rule should only affect those PDF files not found in the old /assets/pdfs/ folder.

<rule name="ABC Help Page redirect" enabled="false" stopProcessing="false">
    <match url="^~abc/assets/(.*)" />  
    <action type="Redirect" url="http://mainsite.org/301ABCHelp.html" appendQueryString="false" />  
</rule>

Changing the stopProcessing value does not seem to make any difference. I don't simply want to say 'Does not match URL', as there are other rewrite rule is place for this site.

share|improve this question
    
It sounds like what you need is a rule to match PDFs (use .pdf instead of .*) and if not found, then redirect to a page on other site, correct? –  dan Jan 10 at 5:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.