IIS环境下PHP rewrite重写设置(支持中文参数)

(编辑:jimmy 日期: 2024/12/25 浏览:2)

在网站根目录下加入:

Web.Config:

<"1.0" encoding=”UTF-8″?>
<configuration>
  <system.webServer>
    <rewrite>
     <rules>
      <rule name="cnUrl" stopProcessing="true">
       <match url="!^(index\.php|images|assets|robots\.txt)" />
       <action type="Rewrite" url="cnurl.php" />
      </rule>
      <rule name="Default" patternSyntax="Wildcard">
       <match url="*" />
        <conditions>
         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
       <action type="Rewrite" url="index.php" />
      </rule>
     </rules>
    </rewrite>
  </system.webServer>
</configuration>

cnurl.php:

<"index.php");

支持IIS环境下跑各种开源PHP项目,如:Wordpress、Emlog、Typecho等。