I do this exact same thing on my Watchguard.
Here is the regex I use, edited to fit the domains you're working with.
(?i)^([^./]+\.)*(grooveshark\.com|gs-cdn\.net)(?![^/])
I'm not sure if you intended to leave the k off grooveshark at one point in your question or if it was just a typo. If they were to use grooveshar.com sometimes then you would need this:
(?i)^([^./]+\.)*(grooveshark?\.com|gs-cdn\.net)(?![^/])
The ? after the k just makes it not necessary.
I highly recommend The Regex Coach to help you build regex.
I also highly recommend http://www.regular-expressions.info/ as a reference.
Using URL Rewrite module v2:
<rule name="CatchAll" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/catchall.aspx?page={REQUEST_URI}" />
</rule>
This rule will catch ALL requests for non-existing files and directories. Usually you will place it at the end (the last or so).
All of such requests will be redirected (internally, of course) to /catchall.aspx
file, the requested URL will be in page
query string parameter. For example, if this page (http://www.example.com/hello-kitten
) will be routed through such catch-all file it will be rewritten to /catchall.aspx?page=/hello-kitten
.
{REQUEST_FILENAME}
: The full local filesystem path to the file or script matching the request. For example:
- Website root:
D:\websites\mysite.com\
- Requested URL:
http://mysite.com/help/delivery
{REQUEST_FILENAME}
= D:\websites\mysite.com\help\delievry
(even if such file/folder does not exist) -- I'm sure you can figure out how it is built from the above example (if virtual folders get involved then it will work a bit differently .. but the general idea is here).
The conditions for this rule, if translated to English, would be: if requested resource is NOT a file AND is NOT a folder, then conditions are met.
URL Rewrite module has IsFile
match type, but has no IsNotFile
. To "simulate" IsNotFile
the IsFile
is used in conjunction with negate="true"
. The same goes for IsDirectory
.
If you access URL Rewrite module via IIS Manager, and click "Edit" on this rule, you will have much easier time with understanding what they do exactly compared to my mumbling (IIS Manager has very good GUI for creating these rules).
Best Answer
Very old post, but it still may help someone.
The following regex worked for me:
(test it on regexr.com)
I added the
|
to the ARGS and URL string, and forbid them before or after.