Reputation: 93
I have next code for .htaccess which works very nice on Apache
RewriteEngine On
RewriteBase /folder
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule index.php.* - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php?id=$1
But I need to run in on server with IIS. Could you help me to translate it for IIS? Thanks a lot.
Upvotes: 1
Views: 2389
Reputation: 31
If you're using IIS 7, you can install URL Rewrite extension for IIS provided by microsoft. This extension also has feature to import .htaccess files. Sometimes, not all of lines can be conveted (see second line of code below). We have to make a little adjustment. Copy and paste the results from 'XML View' tab in import dialog into text editor, and save it as 'web.config' file. Here is your .htaccess converted:
<rewrite>
<!--This directive was not converted because it is not supported by IIS: RewriteBase /folder.-->
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="index.php.*" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="None" />
</rule>
<rule name="Imported Rule 2">
<match url="^(.*)" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?id={R:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
NOTE: direct import result, not yet adjusted.
Upvotes: 1