Help getting started

Topics: User Forum
Sep 27, 2006 at 7:33 PM
Hello,

Great tool, I think it will save me a boatload of time.

I've installed as an ISAPI filter, but I didn't see where to give permissions to the user as instructed in your readme. Perhaps that is my problem as I've tried many of your examples and can't get any to work.

The simplest one:
RewriteRule ^/$ test.cfm

give this in log:
Wed Sep 27 14:16:08 2006 - LogFile re-opened.
Wed Sep 27 14:16:10 2006 - HttpFilterProc SFNOTIFYPREPROC_HEADERS
Wed Sep 27 14:16:10 2006 - DoRewrites
Wed Sep 27 14:16:10 2006 - New Url: '/test/'
Wed Sep 27 14:16:10 2006 - ApplyRules (depth=0)
Wed Sep 27 14:16:10 2006 - Rule 1 : -1
Wed Sep 27 14:16:10 2006 - ApplyRules: returning 0
Wed Sep 27 14:16:10 2006 - No Rewrite

or this one:
RewriteRule ^/(^/\.+)\.(html|htm)(.*)$ /$1.cfm$3

give this in log:
Wed Sep 27 14:30:36 2006 - HttpFilterProc SFNOTIFYPREPROC_HEADERS
Wed Sep 27 14:30:36 2006 - DoRewrites
Wed Sep 27 14:30:36 2006 - New Url: '/test/test.html'
Wed Sep 27 14:30:36 2006 - ApplyRules (depth=0)
Wed Sep 27 14:30:36 2006 - Rule 1 : -1
Wed Sep 27 14:30:36 2006 - ApplyRules: returning 0
Wed Sep 27 14:30:36 2006 - No Rewrite

What would the rule look like if I wanted to have any file (at any level) requested (except .cfm) be passed (with dir struct) to a /getFile.cfm file as a URL variable?

Thanks,
Craig
Sep 27, 2006 at 8:21 PM
OK, I got one of the samples to work, so the dll is installed correctly.

Could you please help me to generate a regex for the example below?

What would the rule look like if I wanted to have any file (at any level) requested (except .cfm) be passed (with dir struct) to a /getFile.cfm file as a URL variable?

Thanks,
Craig
Sep 28, 2006 at 4:17 PM
Looks like I got it. Thanks for the great tool!

RewriteRule (?!^.cfm)^/(.*) /test/act_getFile.cfm?strFile=$1 L
Sep 28, 2006 at 7:36 PM
Jeez, I keep replying to myself here, oh well :)

My last rule was also re-writing .cfm URLs (which I do not want). Hopefully the one below will do the trick. Thanks Craig ;)

RewriteRule (?!cfm$)^/(.*) /test/act_getFile.cfm?strFile=$1 L
Coordinator
Sep 28, 2006 at 7:41 PM
What a great forum this is! Everyone is so helpful!

About your first problem: I know you're already well beyond this, but maybe it will help someone else.

The simplest one:
RewriteRule ^/$ test.cfm

give this in log:
Wed Sep 27 14:16:08 2006 - LogFile re-opened.
Wed Sep 27 14:16:10 2006 - HttpFilterProc SFNOTIFYPREPROC_HEADERS
Wed Sep 27 14:16:10 2006 - DoRewrites
Wed Sep 27 14:16:10 2006 - New Url: '/test/'
Wed Sep 27 14:16:10 2006 - ApplyRules (depth=0)
Wed Sep 27 14:16:10 2006 - Rule 1 : -1
Wed Sep 27 14:16:10 2006 - ApplyRules: returning 0
Wed Sep 27 14:16:10 2006 - No Rewrite

The problem here is the incoming URL '/test/' does not match the regex, which is ^/$. The only thing that matches ^/$ is an incoming URL of / . The ^ signifies beginning-of-line and the $ signifies end-of-line.

Coordinator
Sep 28, 2006 at 7:46 PM
About that last one:

RewriteRule (?!cfm$)^/(.*) /test/act_getFile.cfm?strFile=$1 L

Look at the pattern first. It says, match anything that does not include a 'cfm' in it. the ?! is a negative lookahead. it is a non-matching fragment in the overall pattern. the rest of the pattern says, beginning-of-line, followed by slash, followed by anything. IF that matches the incoming URL, then rewrite.

One update, maybe you should include a \. in the negative lookahead. You want to not match foo.cfm, but I guess you would want to match (and rewrite) something like cfmisgreat.htm . But your negative lookahead will fire on cfmisgreat, which means no match, no rewrite.

The filter itself is pretty simple, it is the regular expression language that is the most challenging for most users to understand.

best,
-Dino

Sep 28, 2006 at 8:01 PM
Yes, I agree. The regex syntax is challenging.

I've changed the regex to be:

RewriteRule (?!.\.cfm)^/(.) /test/act_getFile.cfm?strFile=$1 L

However looking at the most recent post, perhaps I should be excluding .css and .js files. However, I have a question about this; No user is calling the .css or .js file in the address bar of their browser, these must be called in the code. Would the same thing happen to <img src="..> ?

Thanks,
Craig
Sep 29, 2006 at 5:08 PM
One of the best (free) tools I've found for making sure your regular expression does what you think it should be doing is The Regex Coach.

http://weitz.de/regex-coach/

If you like it, support the author with a PayPal donation. (I am in no way related to or affiliated with the author - I just appreciate good free software when I see it; kinda like IIRF. :) )
Coordinator
Oct 3, 2006 at 1:09 AM
.js and.css are requested by the browser when the HTML references them. Yes, something like <img src="...">, but with Javascript and .css , the syntax is different.

<link rel="stylesheet" type="text/css" href="css/stylesheet.css">
<script language="JavaScript" src="javascript/SourceFile.js"></script>