iis 7 - IIS7 web.config file is not supporting redirects and 404 at the same time -


I've written an external redirect file for use in a site, the redirect works perfectly, but when I have a 404 Add rules, redirection breaks. At that point, 404 works, but does not redirection. I web Attempting to keep redirect rules inside the config file (instead of a separate file), but it does not work either.

Can anyone find out how can I get my own redirects working in 404 rules tandem?

Below is the code for redirecting to the web.config file:

   & Lt; Rules & gt; & Lt; Rule name = "Rule 1 redirect for redirect" & gt; & Lt; Mail url = ". *" * / / Gt; & Lt; Conditions & gt; & Lt; Add Input = "{Redirects: {REQUEST_URI}}" Pattern = "(. +)" / & Gt; & Lt; / Status & gt; & Lt; Action Type = "Redirect" url = "{C: 1}" Appendix String = "Fault" /> & Lt; / Rules & gt; & Lt; / Rules & gt; & Lt; / Rewrite & gt; & Lt; /system.webServer> & Lt; / Configuration & gt;   

External file referenced above looks like this:

  & lt; Rewritemaps & gt; & Lt; RewriteMap name = "redirect" & gt; & Lt; Add key = "/ old_page.html" value = "/ new_page.html" / & gt; & Lt; / RewriteMap & gt; & Lt; / RewriteMaps & gt;   

Everything works great at this point however, as soon as I add the following, 404 works great, but redirection does not work.

  & lt; HttpErrors & gt; & Lt; Remove statusCode = "404" subStatusCode = "- 1" /> & Lt; Error status code = "404" prefix target = "" path = "/ page-no-found.html" responseMode = "ExecuteURL" /> & Lt; / HttpErrors & gt;   

The total code that does not work is as follows:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Configuration & gt; & Lt; System.webServer & gt; & Lt; Rewrite & gt; & Lt; RewriteMaps configSource = "rewritemaps.config" /> & Lt; Rules & gt; & Lt; Rule name = "Rule 1 redirect for redirect" & gt; & Lt; Mail url = ". *" * / / Gt; & Lt; Conditions & gt; & Lt; Add Input = "{Redirects: {REQUEST_URI}}" Pattern = "(. +)" / & Gt; & Lt; / Status & gt; & Lt; Action Type = "Redirect" url = "{C: 1}" Appendix String = "Fault" /> & Lt; / Rules & gt; & Lt; / Rules & gt; & Lt; / Rewrite & gt; & Lt; HttpErrors & gt; & Lt; Remove statusCode = "404" subStatusCode = "- 1" /> & Lt; Error status code = "404" prefix target = "" path = "/ page-no-found.html" responseMode = "ExecuteURL" /> & Lt; / HttpErrors & gt; & Lt; /system.webServer> & Lt; / Configuration & gt;    

Your configuration is fine - there is no problem here.

Recycling the app pool or restarting the IIS service.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -