2

I don't have good knowledge about IIS, and I need to convert the following htaccess file to a web.config to enable URL rewrite under IIS.

RewriteEngine On
RewriteRule ^index.html$ index.php [L]
RewriteRule ^/?([0-9a-zA-Z_-]+)/?$ rewrite.php?param1=$1 [L]
RewriteRule ^/?([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/?$ rewrite.php?param1=$1&param2=$2 [L]
RewriteRule ^/?([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/([^/]+)/?$ rewrite.php?param1=$1&param2=$2&param3=$3 [L]

Thanks

Web Jo
  • 97
  • 1
  • 1
  • 5

1 Answers1

0

Your rules could be converted into IIS URL Rewrite Module rules as follows:

<rewrite>
  <rules>
    <rule name="Imported Rule 1" stopProcessing="true">
      <match url="^index.html$" ignoreCase="false" />
      <action type="Rewrite" url="index.php" />
    </rule>
    <rule name="Imported Rule 2" stopProcessing="true">
      <match url="^([0-9a-zA-Z_-]+)/?$" ignoreCase="false" />
      <action type="Rewrite" url="rewrite.php?param1={R:1}" appendQueryString="false" />
    </rule>
    <rule name="Imported Rule 3" stopProcessing="true">
      <match url="^([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/?$" ignoreCase="false" />
      <action type="Rewrite" url="rewrite.php?param1={R:1}&amp;param2={R:2}" appendQueryString="false" />
    </rule>
    <rule name="Imported Rule 4" stopProcessing="true">
      <match url="^([0-9a-zA-Z_-]+)/([0-9a-zA-Z_-]+)/([^/]+)/?$" ignoreCase="false" />
      <action type="Rewrite" url="rewrite.php?param1={R:1}&amp;param2={R:2}&amp;param3={R:3}" appendQueryString="false" />
    </rule>
  </rules>
</rewrite>

See this answer for further reference.

Community
  • 1
  • 1
Alexander Abakumov
  • 13,617
  • 16
  • 88
  • 129
  • @WebJo: If my answer was helpful, could you accept and/or upvote it? It has passed more that a year and this thread seems abandoned/useless for further readers unless you give some feedback. – Alexander Abakumov Dec 14 '15 at 16:49