htaccess文件转换为web.config文件在IIS上运行PHP 7文件、转换为、htaccess、web

2023-09-02 11:27:59 作者:伊

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

 选项+的FollowSymLinks + SymLinksIfOwnerMatch
RewriteEngine叙述上
的RewriteBase /测试
的RewriteCond%{} SCRIPT_FILENAME!-f
的RewriteCond%{} SCRIPT_FILENAME!-d
重写规则^(。*)$的index.php
 

解决方案

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

< XML版本=1.0编码=UTF-8&GT?; <结构>   < system.webServer>     <改写>       <规则>         <规则名称=不存在的路径到index.php>           <匹配URL =^测试/(.+)$/>           <条件>             <添加输入={} REQUEST_FILENAMEmatchType =ISFILE否定=真/>             <添加输入={} REQUEST_FILENAMEmatchType =IsDirectory否定=真/>           &所述; /条件>           <作用TYPE =重写URL =测试/ index.php的appendQueryString =真/>         < /规则>       < /规则>     < /重写>   < /system.webServer> < /结构>

请求 /测试/ 将导致IIS火 /test/index.php (。*)是不必要的,(+)是比较合适的。

怎么建web.config文件

I need to convert .htaccess to web.config in order to run php on iis 7. Any Ideas?

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

解决方案

The URL Rewriting module's import rules from .htaccess wizard generated the following rules:

<?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>

The request /test/ will cause IIS to fire /test/index.php so (.*) is unnecessary and (.+) is more appropriate.