.htaccessiisweb-configisapi-rewriteisapi-redirect

Redirect with bypassing having period (dot) and slash in URL


I have one url which having ./ [period & slash] at the end of parameter. I want to redirect that url with different location but its not even detecting in rules. I am using IIS. I want to configure this on web.config

http://somesitename.com/mypage/teachers-manual./sku/8772

needs to redirect on

http://somesitename.com/mypage/teachers-manual/sku/8772

Though I have tried solution given on Here but its not even working. But if I use same thing instead of Redirect with Rewrite then Rule start working. Not sure why its not working for "Redirect".

<rule name="Trailing Dots and spaces" stopProcessing="true">
<match url="^mypage\/(.*)([\.\s]+)\/(.*)" />
<conditions>
   <add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Rewrite" url="/index.cfm/{R:1}/{R:2}/{R:4}" appendQueryString="true" />
</rule>

Actually when I tried to write rule then url which having ./ is also not working.[ http://somesitename.com/mypage/teachers-manual./sku/8772 ]

 <rule name="Trailing Dots and spaces1.1" stopProcessing="true">
 <match url="^(.*)" />
  <conditions>
    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
  </conditions>
  <action type="Redirect" url="http://somesitename.com/newpage.html" />
 </rule>

Not sure where its wrong.


Solution

  • Just got more information on Post & Haacked Said for it. so I have modified file as follows and now its perfectly working for me.

    <configuration>
      <system.web>
            <httpRuntime relaxedUrlToFileSystemMapping="true" />
      </system.web>
      <system.webServer>
       <rewrite>
        <rules>
         <rule name="Trailing Dots and spaces1.1" stopProcessing="true">
            <match url="^(.*)/(.*)\.\/(.*)" />
             <conditions>
               <add input="{HTTPS}" pattern="off" ignoreCase="true" />
               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
               <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            </conditions>
            <action type="Redirect" url="/{R:1}/{R:2}/{R:3}" appendQueryString="false" redirectType="Permanent" />
         </rule>
       </rules>
     .... etc