This sample demonstrates the use of IIS URL rewrite module to redirect an entire branch of the URL namespace to a single node.js application. This mechanism allows more control over the URL structure of a node.js web service as well as removes the *.js file name from the URL.

visit the endpoint at myapp/foo/bar/baz
visit the endpoint at myapp/1/2/3?param=4
debug the hello.js application at hello.js/debug (requires WebKit enabled browser)


var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end('Hello from urlrewrite sample. Request path: ' + req.url);



    <!-- indicates that the hello.js file is a node.js application 
    to be handled by the iisnode module -->

      <add name="iisnode" path="hello.js" verb="*" modules="iisnode" />

    <!-- use URL rewriting to redirect the entire branch of the URL namespace
    to hello.js node.js application; for example, the following URLs will 
    all be handled by hello.js:
        <rule name="myapp">
          <match url="myapp/*" />
          <action type="Rewrite" url="hello.js" />