URL Rewriting

URL rewriting on IIS is possible only when you install URL Rewriting module on the server.

Please follow the link below to download URL Rewrite module for IIS:

http://www.microsoft.com/en-au/download/details.aspx?id=7435

URL Rewriting is a rule-based mechanism. After the successful installation of the module, you will be able to see an icon for  “URL Rewrite Module”. Create rules for rewriting URLs as per your requirement.

You can write rules for modifying the URLs individually on each website by adding “WEB.CONFIG” with appropriate code.

Ex : Removing ‘.php’ extension from URLs, code for web.config file as follows:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}.php" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="{R:1}.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s