asp.net - How to redirect incoming traffic to another site instead of a 404 page -


im trying configure our iis server redirect users site instead of 404 page.

first of all, maybe title of question not correct have no idea how ask it.

here's deal:

  1. we have lots of documents in our iis server, these documents reports our users, might .pdf, .doc, .xls files etc.
  2. currently of our files stored in 2tb hdd it's getting full , considering attaching hdd store of our current files ( let's call hdd history )
  3. we have many applications , emails sent using url download file hard-coded ( eg. www.somesite.com/documents/file.pdf ) , need deliver files if link sent in email targets "old" url, new hdd create virtual directory named "historydocuments" correct url example before www.somesite.com/historydocuments/file.pdf
  4. i trying following: create url rewrite rule try , check if file exists on "normal" url (documents) if there's no file there, instead of sending 404 page, try jump new virtual directory ( historydocuments ) , try give user file.

all of being done in iis 7.5, don't know if url rewrite correct tool job , haven't found on or interwebs, i'm reaching iis guru teach me way achieve this.

here's image trying illustrate issue: enter image description here

here's web.config section of url rewrite

<rule name="cdocuments rewrite" stopprocessing="true">     <match url=".?" />     <!--<match url="/cdocuments/(.*)?" />-->     <conditions trackallcaptures="true">         <add input="{http_host}" pattern="/cdocuments/(.*)?" />         <add input="{query_string}" pattern="/cdocuments/(.*)?" />     </conditions>     <action type="rewrite" url="http://192.168.172.226/filecheck/default.aspx?file={c:2}" appendquerystring="true" logrewrittenurl="true" /> </rule> 

thanks lot guys.

i don't think iis urlrewrite can this. can customize 404 page on "documents" directory, check if missing file located in old directory , redirect user new url if true. may see many 404 errors in log, not nice.

why not create new directory new documents on new hdd , keep old name old files. old links still work , send links in new url. can create meaningful directories manage documents such www.yourdomain/docs/2015/docufile.pdf. next upgrade easier.

or use iis rewrite

www.yourdomain.com/documents/fileno.pdf 

to

www.yourdomain.com/docs/docfind.asp?fname=fileno.pdf 

and program docfind.asp locate fileno.pdf , redirect user real document url

www.yourdomain.com/historydocuments/fileno.pdf  

or

www.youdomain.com/newdocuments/fileno.pdf 

asp or perl script , easily.

the rule should looks this:

            <rule name="cddocuments">                 <match url="cddocuments/(.*)" />                 <action type="rewrite" url="http://192.168.172.226/filecheck/default.aspx?file={r:1}" />             </rule> 

make sure rename old document directory.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -