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" />


  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Windows IIS Server - Reditect http:// to https://

Using the following code in your web.config file automatically redirects visitors to the HTTPS...

Enabling Cache on Your Windows Hosting Account using clientCache

With our Windows hosting accounts, you can create caching rules to enhance your website's speed...

Disabling Browser Cache on Windows Server static files

The following configuration sample adds an HTTP "Cache-Control: no-cache" header to the response,...

Scheduled Tasks (cron job)

Scheduling Tasks (Windows) If you need to run scripts on your hosting account at specific time,...

500 internal server error - How to Get detailed errors

By default, our Windows hosting accounts display a custom/generic error when applications...