rewrite mobile Users

Topics: Developer Forum, Project Management Forum, User Forum
Jul 24, 2009 at 1:08 PM

Hi there,

 

I'm pretty new to this ISAPI Rewrite method.

I was trying to get Mobile Users to another location then the normal Users.

Because of Using IIS5/6 I read with the ISAPI Filter it would be possible to create rewrite Rules like in the Apache Webserver.

 

What should the ISAPI Filter do?

 

It should read aut the User-Agent and search for the string "Mobile". If it is available it should redirect to in this example google.

 

RewriteLogLevel 4

RewriteEngine On
RewriteCond %{USER_AGENT} (Mobile)

RewriteRule http://www.google.de [L]

 

But I only get logs that try to match an URL instead of the USER-AGENT. How can this be solved?

 

 

Output of Logfile:

Fri Jul 24 15:07:19 -  2280 - LogFile re-opened.
Fri Jul 24 15:07:19 -  2280 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Fri Jul 24 15:07:19 -  2280 - FileChangeWatcher: Await()...
Fri Jul 24 15:07:19 -  2280 - AwaitIniChangeAndReinit: Detected change in the  ini file 'D:\temp\IonicIsapiRewriter-1.2.16-bin\lib\IsapiRewrite4.ini'
Fri Jul 24 15:07:19 -  2280 - AwaitIniChangeAndReinit: Ionic ISAPI Rewriting Filter (IIRF) v1.2.16 R5
Fri Jul 24 15:07:19 -  2280 - ReadConfig
Fri Jul 24 15:07:19 -  2280 - LogFile re-opened.
Fri Jul 24 15:07:19 -  2280 - ReadConfig: new log file name: 'D:\temp\IonicIsapiRewriter-1.2.16-bin\iirfLog.out.8168.log'
Fri Jul 24 15:07:19 -  2280 - ReadConfig: line 2: RewriteLogLevel 4
Fri Jul 24 15:07:19 -  2280 - ReadConfig: setting LogLevel to 4
Fri Jul 24 15:07:19 -  2280 - ReadConfig: line   5: RewriteCond %{USER_AGENT}                                  (Mobile)                                  
Fri Jul 24 15:07:19 -  2280 - ReadConfig: line   7: RewriteRule (rule 1)  'http://www.google.de'  '[L]'   (null)
Fri Jul 24 15:07:19 -  2280 - ReadConfig: Done reading, found 1 rules (0 errors, 0 warnings) on 10 lines

--------------------------------------------
Fri Jul 24 15:07:19 -  2280 - LogFile re-opened.
Fri Jul 24 15:07:19 -  2280 - FileChangeWatcher(): Await returns (TerminateWatch= FALSE)
Fri Jul 24 15:07:19 -  2280 - FileChangeWatcher: Await()...
Fri Jul 24 15:07:24 -  5704 - DllMain THREAD_DETACH
Fri Jul 24 15:07:53 -  6576 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:53 -  6576 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Fri Jul 24 15:07:53 -  6576 - DoRewrites
Fri Jul 24 15:07:53 -  6576 - GetHeader_AutoFree: 'url' = '/'
Fri Jul 24 15:07:53 -  6576 - GetHeader_AutoFree: 'method' = 'GET'
Fri Jul 24 15:07:53 -  6576 - DoRewrites: Url: '/'
Fri Jul 24 15:07:53 -  6576 - EvaluateRules: depth=0
Fri Jul 24 15:07:53 -  6576 - EvaluateRules: Rule 1 : -1 (No match)
Fri Jul 24 15:07:53 -  6576 - EvaluateRules: returning 0
Fri Jul 24 15:07:53 -  6576 - DoRewrites: No Rewrite
Fri Jul 24 15:07:53 -  6576 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:53 -  6576 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:53 -  6576 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Fri Jul 24 15:07:53 -  6576 - DoRewrites
Fri Jul 24 15:07:53 -  6576 - GetHeader_AutoFree: 'url' = '/'
Fri Jul 24 15:07:53 -  6576 - GetHeader_AutoFree: 'method' = 'GET'
Fri Jul 24 15:07:53 -  6576 - DoRewrites: Url: '/'
Fri Jul 24 15:07:53 -  6576 - EvaluateRules: depth=0
Fri Jul 24 15:07:53 -  6576 - EvaluateRules: Rule 1 : -1 (No match)
Fri Jul 24 15:07:53 -  6576 - EvaluateRules: returning 0
Fri Jul 24 15:07:53 -  6576 - DoRewrites: No Rewrite
Fri Jul 24 15:07:53 -  6576 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:54 -  6624 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:54 -  6624 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Fri Jul 24 15:07:54 -  6624 - DoRewrites
Fri Jul 24 15:07:54 -  6624 - GetHeader_AutoFree: 'url' = '/'
Fri Jul 24 15:07:54 -  6624 - GetHeader_AutoFree: 'method' = 'GET'
Fri Jul 24 15:07:54 -  6624 - DoRewrites: Url: '/'
Fri Jul 24 15:07:54 -  6624 - EvaluateRules: depth=0
Fri Jul 24 15:07:54 -  6624 - EvaluateRules: Rule 1 : -1 (No match)
Fri Jul 24 15:07:54 -  6624 - EvaluateRules: returning 0
Fri Jul 24 15:07:54 -  6624 - DoRewrites: No Rewrite
Fri Jul 24 15:07:54 -  6624 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:54 -  6576 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:54 -  6576 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Fri Jul 24 15:07:54 -  6576 - DoRewrites
Fri Jul 24 15:07:54 -  6576 - GetHeader_AutoFree: 'url' = '/'
Fri Jul 24 15:07:54 -  6576 - GetHeader_AutoFree: 'method' = 'GET'
Fri Jul 24 15:07:54 -  6576 - DoRewrites: Url: '/'
Fri Jul 24 15:07:54 -  6576 - EvaluateRules: depth=0
Fri Jul 24 15:07:54 -  6576 - EvaluateRules: Rule 1 : -1 (No match)
Fri Jul 24 15:07:54 -  6576 - EvaluateRules: returning 0
Fri Jul 24 15:07:54 -  6576 - DoRewrites: No Rewrite
Fri Jul 24 15:07:54 -  6576 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:55 -  3960 - HttpFilterProc: SF_NOTIFY_URL_MAP
Fri Jul 24 15:07:55 -  3960 - HttpFilterProc: SF_NOTIFY_AUTH_COMPLETE
Fri Jul 24 15:07:55 -  3960 - DoRewrites
Fri Jul 24 15:07:55 -  3960 - GetHeader_AutoFree: 'url' = '/'
Fri Jul 24 15:07:55 -  3960 - GetHeader_AutoFree: 'method' = 'GET'
Fri Jul 24 15:07:55 -  3960 - DoRewrites: Url: '/'
Fri Jul 24 15:07:55 -  3960 - EvaluateRules: depth=0
Fri Jul 24 15:07:55 -  3960 - EvaluateRules: Rule 1 : -1 (No match)
Fri Jul 24 15:07:55 -  3960 - EvaluateRules: returning 0
Fri Jul 24 15:07:55 -  3960 - DoRewrites: No Rewrite
Fri Jul 24 15:07:55 -  3960 - HttpFilterProc: SF_NOTIFY_URL_MAP

Coordinator
Jul 24, 2009 at 3:04 PM

Your syntax is not correct.  I suggest something like this: 

RewriteLogLevel 3
RewriteLog c:\temp\iirf
StatusUrl /iirfStatus

#
# Any incoming URL request that has User-Agent that includes the string "Mobile",
# will be redirected.

RewriteCond %{USER_AGENT} Mobile
RedirectRule ^(.*)$        http://domain.com/mobile/$1   

The RedirectRule accepts 2 params and one optional param. The first param is the pattern for the URL, the second is the URL you want to redirect to. The optional third param is a set of modifier flags. This is all explained in the .CHM file.   This explains what you saw in the log file. A rule like RewriteRule http://google.com [L] will tell IIRF to match the URL against a pattern like "http://google.com". (It will never match, not on your server)

Jul 28, 2009 at 2:21 PM

Thank you very much. I got it working.

But I have to open a new one