Search code examples
regexmod-rewritezeus

Url rewriting for Zeus - regex help


I've been landed with the unenviable task of putting a site live today only to find out its not running on Apache but instead is using Zeus. Now this breaks my mod_rewrite script rather messily.

Its a simple script which I've rewrote into Zeus format:

RewriteEngine on
RewriteRule !404.php$ blog/404.php [L]

becomes

match URL into $ with ^/blog/(.*)           
if matched set URL=/blog/404.php

However, the downside is that whereas I turned mod_rewrite off in some of the child directories (eg css, images etc) I cant do this in Zeus.

Been playing around with regex to try and get the above regex to exclude any matches for /blog/css/ or /blog/images but no luck.

Hoping someone out there can help me out!

edit. currently working on this regex...

^(?=/blog/)((?!css/|images/|js/).)*$ 

So this should match any link with /blog/ in but exclude those with /blog/css, /blog/js and /blog/images. But it doesnt ><


Solution

  • Ok after trying lots of regex fanciness I went with KISS and came up with this. Hope it helps someone

     match URL into $ with ^/blog/(.*)$   
    if matched 
    match URL into $ with ^/blog/css/(.*)$
    if not matched
    match URL into $ with ^/blog/images/(.*)$
    if not matched
    match URL into $ with ^/blog/js/(.*)$
    if not matched 
        set URL=/blog/404.php
    endif
    endif
    endif
    endif