guru quiz: rewrite every url that does not have a period in it

Topics: Developer Forum
Dec 21, 2007 at 8:13 PM
Edited Dec 21, 2007 at 8:20 PM
Seems like this would be a real easy one to deal with ,but I'm new to regex and this is giving me huge amounts of grief.

I need to rewrite EVERY url that does not have a period in it, tagging the contents onto my controller (index.cfm). Any url with a period in it should pass through untouched.

Here's what I came up with that for whatever reason does not work. It was a hack of something similar I found. I know this can probably be done in a lot less code:

RewriteRule !^.*?\.[^/]{2,5}?.+ /index.cfm?$1 [L]

Can one of you guru's out there throw me a bone?
Dec 22, 2007 at 8:08 AM
Below is another simpler version I tried that should work, but doesnt want to.

RewriteRule !.+\..+ /index.cfm?$1 [L]

What looks wrong with this? Is the "!" pulling everything that does not match the epression?
Dec 26, 2007 at 4:28 AM
I am desperate enough to pay for a solution to this problem, if anyone knows... name your price. Are there some other forums I can hang around that have people who know this rewriting stuff?
Dec 26, 2007 at 5:22 AM
Edited Dec 26, 2007 at 5:25 AM
Here is an excerpt from the log file, trying out a variation of one of the rules above

Tue Dec 25 23:18:36 2007 - ini line 51: RewriteRule 1 !(.+\..+)$ /index.cfm?$1 [L]
Tue Dec 25 23:18:36 2007 - ParseRuleModifierFlags: '[L]'
Tue Dec 25 23:18:36 2007 - Done reading .ini file: Found 1 rules (0 failed) on 52 lines

--------------------------------------------
Tue Dec 25 23:18:36 2007 - LogFile re-opened.
Tue Dec 25 23:18:39 2007 - HttpFilterProc SFNOTIFYURL_MAP
Tue Dec 25 23:18:39 2007 - HttpFilterProc SFNOTIFYAUTH_COMPLETE
Tue Dec 25 23:18:39 2007 - DoRewrites
Tue Dec 25 23:18:39 2007 - New Url: '/sb/chuy/'
Tue Dec 25 23:18:39 2007 - ApplyRules (depth=0)
Tue Dec 25 23:18:39 2007 - Rule 1 : -1 (No match)
Tue Dec 25 23:18:39 2007 - ApplyRules: returning 0
Tue Dec 25 23:18:39 2007 - No Rewrite
Dec 26, 2007 at 5:55 AM
Edited Dec 26, 2007 at 5:59 AM
Tried another one that I thought FOR SURE would work, alas no dice:

#RewriteCond %{URL} !(\.)
#RewriteRule (.*) /index.cfm?$1 [L]

Logs look like this:
Tue Dec 25 23:41:28 2007 - ini line 54: RewriteCond %{URL} !(\.)
Tue Dec 25 23:41:28 2007 - ini line 56: RewriteRule 1 (.*) /index.cfm?$1 [L]
Tue Dec 25 23:41:28 2007 - ParseRuleModifierFlags: 'L'
Tue Dec 25 23:41:28 2007 - Done reading .ini file: Found 1 rules (0 failed) on 57 lines
--------------------------------------------
Tue Dec 25 23:41:31 2007 - EvaluateCondition: checking '/sb/chu/' against pattern '!(\.)'
Tue Dec 25 23:41:31 2007 - Cond : -1 (No match)
Tue Dec 25 23:41:31 2007 - EvaluateConditionList: FALSE, Rule does not apply
Tue Dec 25 23:41:31 2007 - ApplyRules: returning 0
Tue Dec 25 23:41:31 2007 - No Rewrite
Tue Dec 25 23:41:42 2007 - New Url: '/photo/chu/14F34A83-F228-4346-43C72FE87FAD53B0.jpg'
Tue Dec 25 23:41:42 2007 - ApplyRules (depth=0)
Tue Dec 25 23:41:42 2007 - Rule 1 : 2 matches
Tue Dec 25 23:41:42 2007 - EvaluateCondition: checking '/photo/chu/14F34A83-F228-4346-43C72FE87FAD53B0.jpg' against pattern '!(\.)'
Tue Dec 25 23:41:42 2007 - Cond : -1 (No match)
Tue Dec 25 23:41:42 2007 - EvaluateConditionList: FALSE, Rule does not apply
Tue Dec 25 23:41:42 2007 - ApplyRules: returning 0
Tue Dec 25 23:41:42 2007 - No Rewrite
Dec 26, 2007 at 7:15 PM
Finally got it!!

RewriteCond %{URL} ^[^.]*$
RewriteRule (.*) /index.cfm?$1 [L]

Works perfectly!