Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: MyndFyre on May 03, 2006, 08:43 PM

Title: ISAPI Filter for URL Rewriting
Post by: MyndFyre on May 03, 2006, 08:43 PM
Hey.

I'm trying to write a quick-and-dirty ISAPI filter for IIS URL rewriting, to simulate the Wikipedia URL formatting.  I want to make sure I'm doing the right thing.

On IIS, the URL for a MediaWiki installation typically looks like this:

http://host/optional-wiki-subfolder/index.php?title=article-name

...and so I want to translate that to:

http://host/optional-wiki-subfolder/article-name

In the derived class, I'm overwriting CHttpFilter::OnUrlMap.  Is that right?

Also, I need to make sure that the URL is not rewritten if a directory exists under my main application path with what would be the article name.  So far I have /forum, and I'm planning on adding /pub. 

Is there a convenient way to enumerate folders under an IIS virtual path?  Do I just use the Win32 API?  Or, since I'm using MFC, is there an even more convenient way?  :)

Thanks!
Title: Re: ISAPI Filter for URL Rewriting
Post by: UserLoser on May 04, 2006, 02:27 AM
Ew, MFC.

</useless post>
Title: Re: ISAPI Filter for URL Rewriting
Post by: Skywing on May 05, 2006, 06:05 PM
Responded to this via MSN last night, but for the benefit of everyone else:

The answer should be to use GetServerVariable to query the PATH_TRANSLATED variable and operate on that.  For ISAPI extensions (and not filters), you can use ServerSupportFunction with HSE_REQ_MAP_UNICODE_URL_TO_PATH.
Title: Re: ISAPI Filter for URL Rewriting
Post by: Maddox on June 05, 2006, 05:09 AM
Wow, you could do this in one line in .htaccess with apache.
Title: Re: ISAPI Filter for URL Rewriting
Post by: MyndFyre on June 05, 2006, 05:05 PM
Quote from: Maddox on June 05, 2006, 05:09 AM
Wow, you could do this in one line in .htaccess with apache.

Yes, I know, thank you.  Unfortunately for other reasons I am not using Apache.  That is why I wanted to know what a solution could be using MFC.