我坚持重写和重定向规则webconfig。 我想删除文件扩展名并在URL末尾强制添加尾部斜杠我得到了一段代码,但它与文件扩展名一起工作,当我使用隐藏文件扩展名的相同代码时,它将我带到404页面。 仅供参考 - http://example.com/about-us.php/工作正常web.config:隐藏文件扩展名并强制在URL末尾添加尾部斜杠
预期的结果 - http://example.com/about-us/重定向到404页。
请告诉我隐藏文件扩展名的代码,并使用web.config文件同时添加尾部斜线。
我已经应用了,下面我列出了一些规则,斜线增加,但它带我到http://example.com/about-us.php/当我进入浏览器
把http://example.com/about-us仅供参考 - 这是工作的罚款与http://example.com/about-us/但我想http://example.com/about-us网址http://example.com/about-us/
这里是我的规则列表:
<system.webServer>
<httpErrors errorMode="Custom"><!-- For non-managed files -->
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404.php" responseMode="ExecuteURL" />
</httpErrors>
<rewrite>
<rules>
<rule name="Add trailing slash rule 1" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}.php/" />
</rule>
<rule name="Add trailing slash rule 2" stopProcessing="true">
<match url="(.*[^/])" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="{R:1}.php/" redirectType="Permanent" />
</rule>
<rule name="hide php extension" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}.php" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="{R:1}.php/" />
</rule>
</rules>
</rewrite>
</system.webServer>
能否请您添加规则,你试过吗? –