Convert htaccess file to web.config to run Php on IIS 7

五迷三道 提交于 2019-12-25 03:40:11

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/14869747/convert-htaccess-file-to-web-config-to-run-php-on-iis-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!