URL Rewrite/mod_rewrite for Windows on IIS 7.x 8.x

For customers who are looking for a URL rewrite function (like Apache's mod_rewrite) on our Windows 2008 IIS7 or Windows 2012 IIS8 based hosting, Windows IIS 7.5 and IIS8 provide this functionality.  Customers can control this functionality directly in their web.config file on their site.  The following resources may assist you in configuring these options:


Sample web.config for php mod_rewrite

<?xml version="1.0" encoding="UTF-8"?>
<configuration> <configSections>
<sectionGroup name="system.webServer">
<sectionGroup name="rewrite">
<section name="rewriteMaps" overrideModeDefault="Allow" />
<section name="rules" overrideModeDefault="Allow" />

<!-- This section should be uncommented after
installation to secure the installation. -->
<add sequence="engine" />
<add sequence="inc" />
<add sequence="info" />
<add sequence="module" />
<add sequence="profile" />
<add sequence="po" />
<add sequence="sh" />
<add sequence="theme" />
<add sequence="tpl(\.php" />
<add sequence="Root" />
<add sequence="Tag" />
<add sequence="Template" />
<add sequence="Repository" />
<add sequence="code-style" />
<add fileExtension=".sql" allowed="false" />
<add fileExtension=".pl" allowed="false" />
<directoryBrowse enabled="true" />
<add extension=".php" policy="DisableCache" kernelCachePolicy="DisableCache" />
<add extension=".html" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="14:00:00:00" />
<rule name="block favicon" stopProcessing="true">
<match url="favicon\.ico" />
<action type="CustomResponse" statusCode="404" subStatusCode="1"
statusReason="The requested file favicon.ico was not found"
statusDescription="The requested file favicon.ico was not found" />
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<add input="{HTTP_HOST}" pattern="^example\.com$" />

<action type="Redirect" redirectType="Permanent" url="http://www.example.com/{R:1}" />
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" />
<action type="Rewrite" url="index.php?q={R:1}" appendQueryString="true" />
<remove value="index.php" />
<add value="index.php" />

<!-- HTTP Errors section should only be enabled if the "Error Pages"
feature has been delegated as "Read/Write" at the Web Server level.
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/index.php" responseMode="ExecuteURL" />


Was this answer helpful? 0 Users Found This Useful (0 Votes)