Welcome to DavidJSmitty.com Sign in | Join | Help

Using ISAPI_Rewrite Lite with ASP.NET 2 and a dedicated server

Inspired from: http://www.codinghorror.com/blog/archives/000797.html and all the websites out there that have nice-looking URLs.

You have to have a dedicated or virtual dedicated server in order to use IIS plugins such as ISAPI_Rewrite because administrative privilege is required.  You can use ASP.NET UrlMappings to a lesser extent in a shared environment, but you're not going to get away from the .aspx page extension.

Supposing you have a computer you can serve from, and you've installed ASP.NET, you can turn your entire website into a RESTful-seeming site by using the following httpd.ini file.

Restrictions:

  1. No .aspx pages may be nested in the root folder
  2. No folders may have a period in them 


 

[ISAPI_Rewrite]

# /user
# This turns every .aspx page into a "VERB" sort of page, like http://piqd.com/upload
RewriteCond URL (?!.*\.).*
RewriteRule /([^/]*)(.*) /$1.aspx$2  Idea

# /user/q/23
#  You can now append GET parameters to the URL with /VERB/PARAMNAME/PARAMVALUE
RewriteRule (.*?\.aspx)(\?[^/]*)?/([^/]*)/([^/]*)(.*) $1(?2$2&:\?)$3=$4$5 [NS,I]

# /
# If the request is only a /, then redirect to /
RewriteRule /\.aspx / Idea

 

 

Published Monday, July 23, 2007 7:33 AM by david
Filed under: ,

Comments

No Comments
New Comments to this post are disabled