user2071043
user2071043

Reputation: 5

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

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

Upvotes: 0

Views: 4978

Answers (1)

Salman Arshad
Salman Arshad

Reputation: 272126

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.

Upvotes: 1

Related Questions