-->

转换htaccess文件的web.config在IIS上运行PHP 7(Convert htacce

2019-10-29 04:51发布

我需要的.htaccess转换为web.config中,以在IIS 7的任何想法运行php?

Options +FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /test
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php

Answer 1:

从的.htaccess向导URL重写模块的导入规则生成以下规则:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="non-existent paths to index.php">
          <match url="^test/(.+)$" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
          </conditions>
          <action type="Rewrite" url="test/index.php" appendQueryString="true" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

请求/test/将使IIS火/test/index.php所以(.*)是不必要的,并且(.+)是比较合适的。



文章来源: Convert htaccess file to web.config to run Php on IIS 7