Useful header in ISAPI_Rewrite: HTTP_X_REWRITE_URL

I’ve been using ISAPI_Rewrite 3 for some time now to rewrite URLs on my IIS server, and generally to create SEO-friendly URLs.

One thing I only discovered today (and am blogging here mainly for my own future reference) is that for every request, the rewrite engine creates a server variable, HTTP_X_REWRITE_URL, which contains the original requested URL. It was useful for me today, as I was writing a missing page handler, but I can think of many other occasions I’ve had to create complicated workarounds to work out what the requested URL was.

Which brings me to a slight oddity. I’m sure I’d have discovered this incredibly useful feature earlier, if it had shown up when I do a dump of the CGI scope. But for some reason, it doesn’t.

I’ve tried doing a cfdump of the CGI scope; and I’ve tried looping over the scope as a collection; but in neither case does the header get returned.

Yet if I make an explicit reference to CGI.HTTP_X_REWRITE_URL – as if by magic, the URL appears…

I’m sure there’s a perfectly reasonable explanation for this – but I wonder how many other similar variables ColdFusion is choosing not to show us?

Posted at 6:09 PM on 2 December, 2008, in ColdFusion, ISAPI_Rewrite

Leave a comment

Leave this field empty: