asp.net - Remove ASPX FILE Extention in Web.config But Negate Rewrite if URL Contains Period -


all right, of use standard rule below remove aspx extention in urls.

<rule name="remove">       <!--removes .aspx extension pages.-->       <match url="(.*)" />       <conditions logicalgrouping="matchall">         <add input="{request_filename}" matchtype="isfile" negate="true" />         <add input="{request_filename}" matchtype="isdirectory" negate="true" />       </conditions>       <action type="rewrite" url="{r:1}.aspx" />     </rule> 

however modify rule prevent write rule catching url period in it.

that way if tries type in http://www.domain.com/picture.jpg rule doesn't catch it.

luckily isfile , isdirectory conditions prevent actual files being hit rule whenever have case types in file doesn't exist on server rule catches , asp.net this:

http://www.domain.com/404error.aspx?aspxerrorpath=/picture.jpg.aspx

id not pass through rule when there file not found.

basically need able add condition negates whenever period found in url after domain name. i'm assuming sort of regex work. can't seem working right though.

i able come following solution.

        <rule name="rewriteaspx" stopprocessing="true" enabled="true">             <match url="(.*)" />             <conditions logicalgrouping="matchall">                 <add input="{request_filename}" matchtype="isfile" negate="true" />                 <add input="{request_filename}" matchtype="isdirectory" negate="true" />                 <add input="{request_filename}.aspx" matchtype="isfile" />             </conditions>             <action type="rewrite" url="{r:1}.aspx" />         </rule>      

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -