[英]URL rewrite to index.php and remove .php extension with web.config on IIS7
我想實現以下目標-
我在web.config和point#1&3下面使用正常,但在point#2上有問題。 它隱藏了.php,但是當我在URL中添加.php時卻給出了500個內部服務器錯誤,當我在表單動作中添加.php時也給出了500個內部錯誤。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear/>
<add value="index.php" />
<add value="default.html" />
</files>
</defaultDocument>
<security>
<authentication>
<basicAuthentication enabled="true" />
</authentication>
</security>
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/test.html" responseMode="ExecuteURL" />
</httpErrors>
<rewrite>
<rules>
<rule name="RewritePHP">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="?path={R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
<rewrite>
<rules>
<rule name="Imported Rule 1" 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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.