0

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
Salman A
  • 262,204
  • 82
  • 430
  • 521
user2071043
  • 5
  • 1
  • 2
  • 1
    I never understood why people insist on using IIS with all its problem in running things like PHP. But I was told that there is a conversion tool delivered by MS that automatically converts .htaccess style files to what IIS requires instead. Have you tried that tool? – arkascha Feb 14 '13 at 07:41

1 Answers1

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.

Salman A
  • 262,204
  • 82
  • 430
  • 521
  • this might be helpful: http://www.iis.net/learn/extensions/url-rewrite-module/importing-apache-modrewrite-rules – cenk Apr 16 '13 at 21:08