win服務(wù)器下 子目錄 子站偽靜態(tài)辦法分享。 原理很簡單,分享給大家。就是用location 標(biāo)簽 區(qū)分 主站和子目錄的重寫規(guī)則 web.config
雖然目前Linux用戶很多,win服務(wù)器也有很多用戶使用。
根目錄下的 web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="." allowOverride="false" inheritInChildApplications="false">
<system.webServer>
<rewrite>
<rules>
<rule name="已導(dǎo)入的規(guī)則 1" stopProcessing="true">
<match url=".(js|ico|gif|jpe?g|bmp|png|css)$" negate="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>子目錄下的 web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="已導(dǎo)入的規(guī)則2" stopProcessing="true">
<match url=".(js|ico|gif|jpe?g|bmp|png|css)$" negate="true" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="/en/index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>其中/en/ 改成你當(dāng)前子目錄名稱。
以上,用得著的朋友,幫回帖支持下。