Skip to main content
Home
Blog

Main navigation

  • Home
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Knowledge Base
  4. How-To

Microsoft URL Rewrite 101

By ongetc , 26 February, 2017

Microsoft URL rewrite module is extremely easy to use not like Mod_rewrite!

Requirement: IIS 7

Features:

* Rules-based URL rewriting engine.
* Regular expression pattern matching.
* Wildcard pattern matching.
* Global and distributed rewrite rules.
* Access to server variables and HTTP headers.
* Rule templates.
* UI for testing of regular expression and wildcard patterns.
* UI for managing rewrite rules and rewrite maps.
* GUI tool for importing of mod_rewrite rules.
* and much more!

Once this module is installed there are three templates available when you add a new rule and they are:
# User-Friendly URL
# Rule with Rewrite Map
# Request Blocking

With these templates, it will make doing rewrite rule really simple! Plus the UI for testing and importing from mod_rewrite are extremely helpful.

Steps to add new rule:

# Go to IIS Manager
# Select “Default Web Site”
# In the Feature View click “URL Rewrite“
# In the “Actions” pane on right-hand side click on “Add rules…”
# In the "Add Rules" dialog, select the "user-friendly URL" and click "Ok"

That's it!

Create a test page:

Copy the following ASP.NET code and put it in the %SystemDrive%\inetpub\wwwroot\ folder in a file called article.aspx:


<%@ Page Language="C#" %>

URL Rewrite Module Test

URL Rewrite Module Test Page

Server Variable
Value

Original URL:
<%= Request.ServerVariables["HTTP_X_ORIGINAL_URL"] %>

Final URL:
<%= Request.ServerVariables["SCRIPT_NAME"] + "?" + Request.ServerVariables["QUERY_STRING"] %>

Testing the rule

To test that the rule redirects requests correctly, open a Web browser and request the following URL:

http://localhost/article/342/some-article-title
will be rewritten as:
http://localhost/article.aspx?id=342&title=some-article-title.

There are so much more you can do with it!

You can download it here: http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1691

You can get more information here: http://learn.iis.net/page.aspx/734/url-rewrite-module/

Forums
How-To

Reseller hosting (free)

Hosting24 (w/ ssh)

A2 Hosting

Monthly archive

  • September 2009 (14)
  • October 2009 (11)
  • January 2010 (2)
  • June 2010 (3)
  • October 2011 (1)
  • March 2012 (1)
  • July 2012 (1)
  • February 2017 (564)
  • March 2017 (5)
  • April 2017 (2)

Pagination

  • 1
  • Next page

Popular content

Last viewed:

  • PHP Nuke Evolution Xtreme
  • Kalender
  • PHPXref
  • PHP Base Library
  • easyphpalbum
  • PHP Text DB API
  • InterJinnTM
  • How do redirect www using mod_rewrite?
  • Forma Lms
  • PLUME CMS

User login

  • Reset your password