ISAPI Rewrite Filter With Modx and Dynamic Links

Topics: User Forum
Jan 16, 2010 at 3:22 AM

Hi, I am having a little challenge getting the Rewrite filter to do what I want.  I am working in the Modx CMS.

My installation is in the Modx directory. 

Links written as

And being rewritten as the following work fine.

However, using a core piece of Modx code

A dynamic link written as

Is being rewritten as

This returns a file not found error. 

My filter is written as:

RewriteEngine on
RewriteBase /modx
StatusUrl /iirfStatus
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/modx/(.*)$ /modx/index.php?q=$1 [L,QSA]

I am very new to this subject, but I was under the impression that the server still sees the link as "/modx/index.php?id=2&start=3". 

So I am a bit lost here as to what to do.  Any help is much appreciated.

Thank you.  Thomas


Keywords: Modx, IIS, Rewrite Filter, Snippet, Ditto, Dynamic Links, SEO, URL

Jan 16, 2010 at 5:10 PM
Edited Jan 16, 2010 at 5:20 PM

Though you have it in your ini file,  RewriteBase is not supported in IIRF.  There's a workitem that covers how such a function might be added:   If you have input, I'd appreciate it.

Also, the rewriting results you have shown, do not correspond to the rules you have in your ini file.  Maybe Modx is doing the rewriting?  I don't know modx, but your statement "using a core piece of Modx code, a dynamic link written as xxx is being rewritten as yyy" indicates that modx does rewrites.  If Modx does rewrites, I'm not sure what you want out of IIRF.  I don't know how to answer your question.


Jan 17, 2010 at 5:37 AM

I am from Wisconsin and so I say thanks Big Cheeso!  We are the land of Cheese.

When I read your response a lightbulb turned on.  I was looking at rewrite rules backward, something that left-handed dyslectics do. 

I found this Code does work for my installation:

RewriteEngine on
#RewriteBase /modx
StatusUrl /iirfStatus

RewriteRule ^/modx/manager/.* - [L]
RewriteRule ^/modx/assets/.* - [L]
RewriteRule ^/modx/(.*).html /modx/index.php?q=$1 [L,QSA]

However, I question the lack of $ after html on the last RewriteRule.  I add it and I get file not found errors. 

For myself and others, could the above code be written any better in your view?

Further, what surprised me was that the following would be rewritten correctly with the above.




I thought the parts separated by "&" in the url would not all be contained in a single "$1".  Pardon my crude way of explaining.


In addition, on the Modx CMS system it is important to not cache pages that have code for dynamic pages.  Specifically for others reading this, on a page

with a dynamic link it is important to uncheck "Cachable".  Between these things and not the right code I was challenged.  For your information, Modx allows the users to specify a suffix (and for that matter a prefix) to the alias.  I chose to use .html


Thank you again.  Thomas