问题
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