简体   繁体   中英

web.config redirecting folder name to file name

I hosted my site on windows server. I am trying to redirect user to a .html file inside web server when user browse sitename.com/foldername/

What tag should I add or modify in web.config file to achieve this. I used .htaccess file when I worked on linux hosting server.

first you must install url rewrite extension for iis,and then use this config in your webconfig file:

<system.webServer>
<rewrite>
  <rules>
    <rule name="redirecting to html file" stopProcessing="true">
      <match url="sitename.com/foldername/" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="your html file address" />
    </rule>
  </rules>
</rewrite>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM