如何在驻留内部文件夹的网站中设置URL重写

时间:2018-10-09 09:03:38

标签: c# asp.net iis url-rewriting iis-8.5

如何从文件夹映射默认文档文件。那里有一个index.html文件。

sitename.com —> root/folder1
sitename.com/url1 —> root/folder2
sitename.com/url2 —> root/folder3 

我配置为

<rule name="rootFolder1" stopProcessing="true">
   <match url="^.*$" />
   <action type="Rewrite" url="/folder1/{R:0}" />
</rule>

<rule name="rootfolder2" stopProcessing="true">
   <match url="^url1.*$" />
   <action type="Rewrite" url="/folder2/" />
</rule>

<rule name="rootfolder3" stopProcessing="true">
   <match url="^url2.*$" />
   <action type="Rewrite" url="/folder3/" />
</rule>

js文件和css文件不适用于该folder2和folder3。它们取自folder1。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

决定我的问题

 <rule name="rootfolder2" stopProcessing="true">
        <match url="url1(.*)" />
        <action type="Rewrite" url="/folder2/{R:1}" />
    </rule>
    <rule name="rootfolder3" stopProcessing="true">
        <match url="url2(.*)" />
        <action type="Rewrite" url="/folder3/{R:1}" />
    </rule>
    <rule name="rootfolder1" stopProcessing="true">
        <match url="^.*$" />
        <action type="Rewrite" url="/folder1/{R:0}" />

感谢lex-li