Why are some Rewrite/Redirect Rules Work, and others don't?

Topics: User Forum
Jul 29, 2010 at 6:53 AM

I have been hours on this trying figure it out. Some of my Rules work, and others don't:

 

RewriteLog E:\webs\SierraGems.net\IIRF-Log.txt
RewriteLogLevel 3

RewriteCond %{REMOTE_ADDR} 10.10.1.0
RewriteRule ^/(.*)$ /$1 [F]

#ALL of these WORK Correctly
RedirectRule ^/Page\.asp\?page=1$ /AskandAnswer.asp [R=301]
RewriteRule ^/AskandAnswer.asp$ /Page.asp?page=1 [L]
RedirectRule ^/Page\.asp\?page=2$ /ShareIdeas.asp [R=301]
RewriteRule ^/ShareIdeas.asp$ /Page.asp?page=2 [L]

#THESE RESULT IN a 404 Page Not Found

RedirectRule ^/proddetail\.asp\?prod=BYTPRN6MM$ /6mmPrincessCutBytownite.asp [R=301]
RewriteRule ^/6mmPrincessCutBytownite.asp$ /proddetail.asp?prod=BYTPRN6MM [L]
RedirectRule ^/proddetail\.asp\?prod=BYTPRN5MM$ /5mmPrincessCutBytownite.asp [R=301]
RewriteRule ^/5mmPrincessCutBytownite.asp$ /proddetail.asp?prod=BYTPRN5MM [L]
RedirectRule ^/proddetail\.asp\?prod=BYTPRN7MM$ /7mmPrincessCutBytownite.asp [R=301]
RewriteRule ^/7mmPrincessCutBytownite.asp$ /proddetail.asp?prod=BYTPRN7MM [L]
RedirectRule ^/proddetail\.asp\?prod=BYTPRN8MM$ /8mmPrincessCutBytownite.asp [R=301]
RewriteRule ^/8mmPrincessCutBytownite.asp$ /proddetail.asp?prod=BYTPRN8MM [L]

I have built a dynamic script that builds the IIRF.ini file, and have had it work on other sites.

I have a log file to review

 

Wed Jul 28 22:26:49 -  5132 - -------------------------------------------------------
Wed Jul 28 22:26:49 -  5132 - Ionic ISAPI Rewriting Filter (IIRF) 2.0.1.15 RELEASE
Wed Jul 28 22:26:49 -  5132 - IIRF was built on: Dec  3 2009 11:49:15
Wed Jul 28 22:26:49 -  5132 - Cached: DLL_PROCESS_ATTACH
Wed Jul 28 22:26:49 -  5132 - Cached: Process ID: 1040
Wed Jul 28 22:26:49 -  5132 - Cached: DLL_PROCESS_ATTACH - complete
Wed Jul 28 22:26:49 -  5132 - Cached: GetFilterVersion
Wed Jul 28 22:26:49 -  5132 - GetLogFile: app:'/LM/W3SVC/78/ROOT'  new log:'E:\webs\SierraGems.net\IIRF-Log.txt.1040.log'
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: actual log file 'E:\webs\SierraGems.net\IIRF-Log.txt.1040.log'
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: ini file: 'E:\webs\SierraGems.net\wwwroot\Iirf.ini'
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: ini file timestamp: 2010/07/28 21:55:19 Pacific Daylight Time
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line   2: LogLevel = 3
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line   4: RewriteCond   %{REMOTE_ADDR}  10.10.1.0
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line   5: RewriteRule (rule 1)  '^/(.*)$'  '/$1'      [F]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line   7: RedirectRule (rule 2)  '^/Page\.asp\?page=1$'  '/AskandAnswer.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 7: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line   8: RewriteRule (rule 3)  '^/AskandAnswer.asp$'  '/Page.asp?page=1'      [L]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line   9: RedirectRule (rule 4)  '^/Page\.asp\?page=2$'  '/ShareIdeas.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 9: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  10: RewriteRule (rule 5)  '^/ShareIdeas.asp$'  '/Page.asp?page=2'      [L]

[I truncated some of the records here because they are basically the same]

SO what is happening with the following???????????????????

Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  47: RedirectRule (rule 42)  '^/proddetail\.asp\?prod=BYTPRN6MM$'  '/6mmPrincessCutBytownite.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 47: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  48: RewriteRule (rule 43)  '^/6mmPrincessCutBytownite.asp$'  '/proddetail.asp?prod=BYTPRN6MM'      [L]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  49: RedirectRule (rule 44)  '^/proddetail\.asp\?prod=BYTPRN5MM$'  '/5mmPrincessCutBytownite.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 49: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  50: RewriteRule (rule 45)  '^/5mmPrincessCutBytownite.asp$'  '/proddetail.asp?prod=BYTPRN5MM'      [L]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  51: RedirectRule (rule 46)  '^/proddetail\.asp\?prod=BYTPRN7MM$'  '/7mmPrincessCutBytownite.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 51: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  52: RewriteRule (rule 47)  '^/7mmPrincessCutBytownite.asp$'  '/proddetail.asp?prod=BYTPRN7MM'      [L]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  53: RedirectRule (rule 48)  '^/proddetail\.asp\?prod=BYTPRN8MM$'  '/8mmPrincessCutBytownite.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 53: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  54: RewriteRule (rule 49)  '^/8mmPrincessCutBytownite.asp$'  '/proddetail.asp?prod=BYTPRN8MM'      [L]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: line  55: RedirectRule (rule 50)  '^/proddetail\.asp\?prod=BYTPRN9MM$'  '/9mmBytownitePrincessCut.asp'  [R=301]
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: INFO: line 55: Redirecting to a target that does not include an http(s):// scheme.
Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig:                The rule will Redirect to a target on the local machine

Wed Jul 28 22:26:49 -  5132 - ReadSiteConfig: Done reading, found 229 rules (0 errors, 0 warnings) on 235 lines
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Wed Jul 28 22:26:49 -  5132 - DoRewrites
Wed Jul 28 22:26:49 -  5132 - DoRewrites: Url (no decoding): '/'
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: depth=0
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 1 : 2 matches
Wed Jul 28 22:26:49 -  5132 - EvalCondition: Cond %{REMOTE_ADDR} 10.10.1.0 => FALSE
Wed Jul 28 22:26:49 -  5132 - EvalConditionList: rule 1, FALSE, Rule does not apply
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 2 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 3 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 4 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 5 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 6 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 7 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 8 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 9 : -1 (No match)
Wed Jul 28 22:26:49 -  5132 - EvaluateRules: Rule 10 : -1 (No match) [These lines end at Rule 229]

[Continued]

Wed Jul 28 22:26:49 -  5132 - EvaluateRules: returning 0
Wed Jul 28 22:26:49 -  5132 - DoRewrites: No Rewrite
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:49 -  5132 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  3260 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  5204 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:50 -  4156 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:51 -  5132 - HttpFilterProc: SF_NOTIFY_URL_MAP
Wed Jul 28 22:26:51 -  5132 - HttpFilterProc: cfg= 0x028A41C0
Wed Jul 28 22:26:51 -  5132 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Wed Jul 28 22:26:51 -  5132 - DoRewrites
Wed Jul 28 22:26:51 -  5132 - DoRewrites: Url (no decoding): '/styles/styles.css'
Wed Jul 28 22:26:51 -  5132 - EvaluateRules: depth=0
Wed Jul 28 22:26:51 -  5132 - EvaluateRules: Rule 1 : 2 matches
Wed Jul 28 22:26:51 -  5132 - EvalCondition: Cond %{REMOTE_ADDR} 10.10.1.0 => FALSE
Wed Jul 28 22:26:51 -  5132 - EvalConditionList: rule 1, FALSE, Rule does not apply
Wed Jul 28 22:26:51 -  5132 - EvaluateRules: Rule 2 : -1 (No match)
Wed Jul 28 22:26:51 -  5132 - EvaluateRules: Rule 3 : -1 (No match)
Wed Jul 28 22:26:51 -  5132 - EvaluateRules: Rule 4 : -1 (No match)
Wed Jul 28 22:26:51 -  5132 - EvaluateRules: Rule 5 : -1 (No match) 

[And it just seems to repeat the same lines again]

Coordinator
Jul 29, 2010 at 1:23 PM
What do you expect to see? Nothing in the log looks really odd, to me. The first rule is not matching because of the rewritecond. That is obvious, right? I suppose the REMOTE_ADDR is evaluating to something other than 10.10.1.0 (or whatever you had in that rule). If you turn up the log level you'll see what that rewritecond is doing.
Jul 29, 2010 at 6:30 PM

I was hoping to see why my second sets of Rules are not working, causing the 404 Page Not Found error

RedirectRule ^/proddetail\.asp\?prod=BYTPRN6MM$ /6mmPrincessCutBytownite.asp [R=301]
RewriteRule ^/6mmPrincessCutBytownite.asp$ /proddetail.asp?prod=BYTPRN6MM [L]

I set the Log Level to 4 and I will try that.

Right now my server is being looked at because it crashed from IIRF trying to write to a non-existent log file because I didn't put a blank log file into the specified folder