% issue WSS SSL redirect

Topics: Developer Forum, Project Management Forum, User Forum
May 29, 2008 at 5:15 PM
I am attempting to create a method of providing sites in either SSL or non-ssl dependant on DNS.

So far here is how it works:
In DNS I have a zone, which for lab purposes is wss.ul02.local I will have a wildcard entry for *.wss.ul02.local which points to my non-ssl FrontEnd IP.

the Web app. is extended to a second IIS site which has a certificate, and SSL enabled and its own IP, in DNS, if I wnat a site to have SSL, I point it to this IP instead using an explicit entry for that fqdn. Here is where it gets tricky:

Since these SSL sites could be mistakenly accessed by the user w/o specifying the https prefix, or any prefix at all, I have set found your filter useful in this way:

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [I,RP]

...This redirects incoming traffic to the SSL port and makes it all happy. This works great.

Here is where I have a problem:

SharePoint's search uses the host header to limit the search to a specific site collection. This host header is also stored in the search database. the current setup means all sites are crawled using http, and so are stored this way. When you run a search in WSS the .aspx page pulls your host header to narrow the search automatically. If you are accessng the site using SSL, it will pull https://test.wss.ul02.local from the browser, but the search database has it as http://test.ul02.local. The result is no results.

The URL is formed by default as follows, assuming I searched for 'network':

https://test.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Ftest%2Ewss%2Eul02%2Elocal

That is what the browser will be instructed to load. What I need is to omit the s un u=https, and leave everything else unchanged before it is passed to the app pool:

https://test.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=http%3A%2F%2Ftest%2Ewss%2Eul02%2Elocal

This will allow the page to properly return results...

Here is what I had tried:

RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
RewriteRule ^(\_layouts/searchresults\.aspx)$ /$1?%1%3 [L]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [I,RP]

The first two lines are the new ones to try to handle this... It does not result in any change to the URL. The http-https redirection seems to work as planned.

Here are the logs from when a search is done:

Thu May 29 10:07:03 2008 - New Url: '/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Thu May 29 10:07:03 2008 - ApplyRules (depth=0)
Thu May 29 10:07:03 2008 - Rule 1 : -1 (No match)
Thu May 29 10:07:03 2008 - Rule 2 : 2 matches
Thu May 29 10:07:03 2008 - GetServerVariable: getting 'SERVER_PORT'
Thu May 29 10:07:03 2008 - GetServerVariable: xferred 4 bytes
Thu May 29 10:07:03 2008 - GetServerVariable: result '443'
Thu May 29 10:07:03 2008 - ReplaceServerVariables: VariableName='SERVER_PORT' Value='443'
Thu May 29 10:07:03 2008 - ReplaceServerVariables: InputString='%{SERVER_PORT}' out='443'
Thu May 29 10:07:03 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal','(null)' ReplacePattern='443' vec=[[  [  0, 84, 1, 84] [] ] counts=2,0
Thu May 29 10:07:03 2008 - EvaluateCondition: checking '443' against pattern '^80$'
Thu May 29 10:07:03 2008 - Cond : -1 (No match)
Thu May 29 10:07:03 2008 - Cond : Child is NULL
Thu May 29 10:07:03 2008 - EvaluateConditionList: FALSE, Rule does not apply
Thu May 29 10:07:03 2008 - ApplyRules: returning 0
Thu May 29 10:07:03 2008 - No Rewrite


Is there something wrong with my regex? Have I implemented this poorly somehow? I'm not sure what to try from here. Please let me know.

Thanks!
May 29, 2008 at 5:50 PM
Also, this may make the issue a bit clearer, maybe this is a bug, or I did it wrong...

Here is my ini:
RewriteLog  C:\temp\iirfLog.out
RewriteLogLevel 5
RewriteFilterPriority HIGH
RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
# RewriteRule ^(/searchresults\.aspx)$ /$1?%1%3 [L]
RewriteRule ^/(.*)$ /$1?%1%3 [L]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [I,RP]

Here is the output from the log:
Thu May 29 13:35:24 2008 - New Url: '/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Thu May 29 13:35:24 2008 - ApplyRules (depth=0)
Thu May 29 13:35:24 2008 - Rule 1 : 2 matches
Thu May 29 13:35:24 2008 - GetServerVariable: getting 'QUERY_STRING'
Thu May 29 13:35:24 2008 - GetServerVariable: xferred 56 bytes
Thu May 29 13:35:24 2008 - GetServerVariable: result 'k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Thu May 29 13:35:24 2008 - ReplaceServerVariables: VariableName='QUERY_STRING' Value='k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Thu May 29 13:35:24 2008 - ReplaceServerVariables: InputString='%{QUERY_STRING}' out='k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Thu May 29 13:35:24 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal','(null)' ReplacePattern='k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal' vec=[[  [  0, 84, 1, 84] [] ] counts=2,0
Thu May 29 13:35:24 2008 - GenerateReplacementString: Substring index out of range (%3)
Thu May 29 13:35:24 2008 - GenerateReplacementString: Substring index out of range (%2)
Thu May 29 13:35:24 2008 - GenerateReplacementString: Substring index out of range (%2)
Thu May 29 13:35:24 2008 - GenerateReplacementString: Substring index out of range (%2)
Thu May 29 13:35:24 2008 - GenerateReplacementString: Substring index out of range (%2)
Thu May 29 13:35:24 2008 - GenerateReplacementString: Substring index out of range (%2)
Thu May 29 13:35:24 2008 - EvaluateCondition: checking 'k=network&u=httpsAFFteamsiteEwssEul02Elocal' against pattern '^((.*&)?u=http)s(.+)$'
Thu May 29 13:35:24 2008 - Cond : 4 (match)
Thu May 29 13:35:24 2008 - Cond : Child is NULL
Thu May 29 13:35:24 2008 - EvaluateConditionList: TRUE, Rule will apply
Thu May 29 13:35:24 2008 - ReplaceServerVariables: InputString='/$1?%1%3' out='/$1?%1%3'
Thu May 29 13:35:24 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal','k=network&u=httpsAFFteamsiteEwssEul02Elocal' ReplacePattern='/$1?%1%3' vec=[[  [  0, 84, 1, 84] [  0, 43, 0, 16, 0, 10, 17, 43] ] counts=2,4
Thu May 29 13:35:24 2008 - GenerateReplacementString: replacing ($1) with _layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal
Thu May 29 13:35:24 2008 - GenerateReplacementString: replacing (%1) with k=network&u=http
Thu May 29 13:35:24 2008 - GenerateReplacementString: replacing (%3) with AFFteamsiteEwssEul02Elocal
Thu May 29 13:35:24 2008 - Result (length 127): /_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal?k=network&u=httpAFFteamsiteEwssEul02Elocal
Thu May 29 13:35:24 2008 - Last if Match
Thu May 29 13:35:24 2008 - ApplyRules: returning 1
Thu May 29 13:35:24 2008 - Rewrite Url to: '/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal?k=network&u=httpAFFteamsiteEwssEul02Elocal'


If you notice from the logs it keeps complaining about %2 and %3 in the original URL... Those are not being preserved during the manipulation as part of the URL, not variables. Any ideas?
Coordinator
May 30, 2008 at 11:27 PM

The logs in your first post indicate that the SERVER_PORT is 443.  Your RewriteCond is matching that against 80.  This does not match, which means the RewriteCond evaluates to false, which means the RewriteRule itself is not executed (or applied). 

Does that help?

 

Jun 9, 2008 at 4:01 PM
Sorry I did not get back to you sooner, I was out of town for a week:

The logs in the first post, I can see what you are saying.

How can I get it to evaluate those two events completely separately?

Such that if it matches this: RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
Then rewrite to this: RewriteRule ^(/_layouts/searchresults\.aspx)$ /$1?%1%3 [L]

And then so that no matter what, any URL that matches this: %{SERVER_PORT} ^80$
Get switched to https: RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,I,RP]

The end result is that I want all traffic to this IIS virtual to be https, even if it wasn't specified by the user, if it isn't redirect, and also, I want any url that has 'u=https' in the query string to be rewritten without the 's'. as below:
From: https://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal
To: https://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=http%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

And even if somehow something crazy happens, perhaps the site was not using SSL, but now is, but they had a bookmark to the search result or something, then it should be:
From any of:
http://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal
http://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=http%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal
https://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

Should come back with: https://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=network&u=http%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal


Also keeping in mind that the k=network portion is the user's search and cannot be coded into the rules, in this case I was searching for network.


I also tested this w/o the http-https rewrite rules, and get this in log:

Mon Jun 09 11:58:23 2008 - New Url: '/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Mon Jun 09 11:58:23 2008 - ApplyRules (depth=0)
Mon Jun 09 11:58:23 2008 - Rule 1 : -1 (No match)
Mon Jun 09 11:58:23 2008 - ApplyRules: returning 0
Mon Jun 09 11:58:23 2008 - No Rewrite

Using in ini file:

RewriteLog  C:\temp\iirfLog.out
RewriteLogLevel 5
RewriteFilterPriority HIGH
RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
RewriteRule ^(/_layouts/searchresults\.aspx)$ /$1?%1%3 [L]
Coordinator
Jun 10, 2008 at 3:46 AM
Sorry, that was a little too much information for me.
maybe you can break it down into parts.

what specifically do you want to do?  In parts.
Sounds like one part is to redirect all http traffic to https.

have you got that working? 

let's take care of that and then move onto the next thing, hmm?    
Jun 10, 2008 at 2:22 PM
Edited Jun 10, 2008 at 2:42 PM
Thanks for your patience on this.

The http redirect works, any traffic that comes in on port 80 is redirected to https using this:

RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,I,RP]

No trouble there, the trouble is with part 2, which is to check a query string for 'u=https' and strip out the 's', otherwise leave it alone.
I have a regex ready which matches to 3 parts:

^((.*&)?u=http)s(.+)$

So, in the sample URL below:
/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

%1 = k=network&u=http
%2 = k=network
%3 = %3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

The plan then is to rewrite the URL with just %1%3, this is the part I am struggling with. I have the following line:

RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
RewriteRule ^/(.*)$ /_layouts/searchresults.aspx?%1%3 [L]

Which seems to match it correctly, but I do not know how to then make it perform the rewrite correctly. When the rewrite happens from these rules, the result from the logs is:

Rewrite Url to: '/_layouts/searchresults.aspx?k=network&u=httpAFFteamsiteEwssEul02Elocal'

Notice how the %3A%2F%2F in the original URL are now AFF in the result, and all %2E strings are now just E.

Thanks.
Jun 10, 2008 at 2:46 PM
Here is the full log output from that session which almost worked except it stripped out the %2's and %3's

Tue Jun 10 10:35:34 2008 - New Url: '/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Tue Jun 10 10:35:34 2008 - ApplyRules (depth=0)
Tue Jun 10 10:35:34 2008 - Rule 1 : 2 matches
Tue Jun 10 10:35:34 2008 - GetServerVariable: getting 'SERVER_PORT'
Tue Jun 10 10:35:34 2008 - GetServerVariable: xferred 4 bytes
Tue Jun 10 10:35:34 2008 - GetServerVariable: result '443'
Tue Jun 10 10:35:34 2008 - ReplaceServerVariables: VariableName='SERVER_PORT' Value='443'
Tue Jun 10 10:35:34 2008 - ReplaceServerVariables: InputString='%{SERVER_PORT}' out='443'
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal','(null)' ReplacePattern='443' vec=[[  [  0, 84, 1, 84] [] ] counts=2,0
Tue Jun 10 10:35:34 2008 - EvaluateCondition: checking '443' against pattern '^443$'
Tue Jun 10 10:35:34 2008 - Cond : 1 (match)
Tue Jun 10 10:35:34 2008 - Cond : Child is non NULL
Tue Jun 10 10:35:34 2008 - Cond : Current condition evaluates to TRUE
Tue Jun 10 10:35:34 2008 - Cond : Logical AND, ergo we evaluate the Child
Tue Jun 10 10:35:34 2008 - GetServerVariable: getting 'QUERY_STRING'
Tue Jun 10 10:35:34 2008 - GetServerVariable: xferred 56 bytes
Tue Jun 10 10:35:34 2008 - GetServerVariable: result 'k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Tue Jun 10 10:35:34 2008 - ReplaceServerVariables: VariableName='QUERY_STRING' Value='k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Tue Jun 10 10:35:34 2008 - ReplaceServerVariables: InputString='%{QUERY_STRING}' out='k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal'
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal','443' ReplacePattern='k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal' vec=[[  [  0, 84, 1, 84] [  0, 3] ] counts=2,1
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: Substring index out of range (%3)
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: Substring index out of range (%2)
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: Substring index out of range (%2)
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: Substring index out of range (%2)
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: Substring index out of range (%2)
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: Substring index out of range (%2)
Tue Jun 10 10:35:34 2008 - EvaluateCondition: checking 'k=network&u=httpsAFFteamsiteEwssEul02Elocal' against pattern '^((.*&)?u=http)s(.+)$'
Tue Jun 10 10:35:34 2008 - Cond : 4 (match)
Tue Jun 10 10:35:34 2008 - Cond : Child is NULL
Tue Jun 10 10:35:34 2008 - EvaluateConditionList: TRUE, Rule will apply
Tue Jun 10 10:35:34 2008 - ReplaceServerVariables: InputString='/_layouts/searchresults.aspx?%1%3' out='/_layouts/searchresults.aspx?%1%3'
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal','k=network&u=httpsAFFteamsiteEwssEul02Elocal' ReplacePattern='/_layouts/searchresults.aspx?%1%3' vec=[[  [  0, 84, 1, 84] [  0, 43, 0, 16, 0, 10, 17, 43] ] counts=2,4
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: replacing (%1) with k=network&u=http
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: replacing (%3) with AFFteamsiteEwssEul02Elocal
Tue Jun 10 10:35:34 2008 - Result (length 71): /_layouts/searchresults.aspx?k=network&u=httpAFFteamsiteEwssEul02Elocal
Tue Jun 10 10:35:34 2008 - Last if Match
Tue Jun 10 10:35:34 2008 - ApplyRules: returning 1
Tue Jun 10 10:35:34 2008 - Rewrite Url to: '/_layouts/searchresults.aspx?k=network&u=httpAFFteamsiteEwssEul02Elocal'
Tue Jun 10 10:35:34 2008 - HttpFilterProc SF_NOTIFY_URL_MAP
Tue Jun 10 10:35:34 2008 - HttpFilterProc SF_NOTIFY_URL_MAP
Tue Jun 10 10:35:34 2008 - HttpFilterProc SF_NOTIFY_URL_MAP
Tue Jun 10 10:35:35 2008 - DllMain THREAD_DETACH, threadId= 2036

Jun 10, 2008 at 6:30 PM
I think I figured out the simplest way to word the 'problem'.

The URL passed from the browser to the server is:
/_layouts/searchresults.aspx?k=network&u=https%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

In a regex builder I confirmed that ^((.*&)?u=http)s(.+)$ gives me:
%1 = k=network&u=http
%2 = k=network
%3 = %3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

Unfortunately, when the ISAPI filter parses the string and regex, I get:
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: replacing (%1) with k=network&u=http
Tue Jun 10 10:35:34 2008 - GenerateReplacementString: replacing (%3) with AFFteamsiteEwssEul02Elocal

Thus, I have in %3: AFFteamsiteEwssEul02Elocal
...going to IIS for processing...
But I should have in %3: %3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal


How do I get the filter to not strip out the %3 and %2 strings in the URL which was passed to the server from the browser? Once that is resolved, I should be seeing in the logs:
GenerateReplacementString: replacing (%3) with %3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal
Instead of: GenerateReplacementString: replacing (%3) with AFFteamsiteEwssEul02Elocal

Hope that helps.
Coordinator
Jun 11, 2008 at 8:41 PM
Edited Jun 11, 2008 at 9:04 PM

Yes, that helps.
What version of the filter are you using?
There was a workitem 15185, that addressed a related issue.
http://www.codeplex.com/IIRF/WorkItem/View.aspx?WorkItemId=15185

The fix for 15185 is in the latest thing labeled "1.2.14b preview".  
It should properly pass-through the %3A and %2F and etc, in your URLs.

In other words, with that binary you should get the behavior you want.

Grab the binary and try it?

Jun 12, 2008 at 4:29 AM
Awesome, thanks a lot.

I tried using 1.2.12b, c, and d.. All same results.

Swapping out the DLL shouldn't be an issue with this, I will try it in the AM and post back the results
Jun 12, 2008 at 3:18 PM
Ok, so I killed off IIS, then replaced the DLL, started IIS, changed nothing else, and it works as expected!
You rock, thanks for the help on this, your tool just fixed SharePoint :)

*so very happy*
Coordinator
Jun 12, 2008 at 3:23 PM
Glad it's working for you!!

what was wrong with Sharepoint anyway?
Jun 12, 2008 at 3:45 PM
In SharePoint I have a web application set up, with an extension. So, I have one web application that runs in an IIS virtual on port 80, and the exension of that web app. run in a virtual on port 443 for SSL. Doing this allows me to have one IP address to access a site collection using SSL, and a different IP address for non-SSL. Then what I do is have multiple site collections.

In my lab I have DNS set up to have a wildcard that points to non-SSL, and then explicit entries to redirect certain sites to the SSL virtual.

zone: wss.ul02.local
*.wss.ul02.local               192.168.237.100
teamsite.wss.ul02.local     192.168.237.105

So, I did not want the end users to have to specify if they use SSL or not in the browser, thus I needed on the SSL virtual a general redirect to use SSL, which worked great from the start. SSL is controled in DNS now.

The problem is with WSS Search:

The indexer is configured on the web application level, the web application is non-SSL, so the indexer indexes the sites with the non-SSL hostheader:
http://blanksite.wss.ul02.local
http://teamsite.wss.ul02.local

If in DNS I said teamsite should use SSL, then the browser goes to https://teamsite.wss.ul02.local, and loads the page, when you enter a search, SharePoint grabs your browser URL string and sends that to the search server for results:

https://teamsite.wss.ul02.local != http://teamsite.wss.ul02.local as was indexed, no results.

Using SSL breaks search, so, I needed to rewrite the URL before SharePoint sees it:

https://teamsite.wss.ul02.local/_layouts/searchresults.aspx?k=keywordsearched&u=http%3A%2F%2Fteamsite%2Ewss%2Eul02%2Elocal

This will force the search to run on the non-SSL site in the index, and I get results!

The results are all links to the non-SSL site, but this doesn't matter because it is already fixed with the redirect from before, so you click a link in the results to get to an item, and the redirect keeps you on the SSL site.

Here is my INI file for your reference:

RewriteLog  C:\temp\iirfLog.out
RewriteLogLevel 1
RewriteFilterPriority HIGH
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
RewriteRule ^/(.*)$ /_layouts/searchresults.aspx?%1%3 [L]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,I,RP]

Let me know if you need any clarifications.
Coordinator
Jun 12, 2008 at 5:03 PM
Edited Jun 12, 2008 at 7:34 PM

Wow! 

Hey thanks for the explanation, very clear. I'm glad you found IIRF, and I'm glad you got it to work for your purposes.

 (ps: what is the RP in the flags for the final  rewrite rule?  I think that is a flag for use with the commercial IsapiRewrite thing, which stands for "moved permanently"?   The IIRF equivalent is R=301.  The RP is ignored by IIRF. )

Just to let you know, I am recently accepting donations from people who like IIRF.  I give all donations to charity.  See http://cheeso.members.winisp.net/IirfDonate.aspx

Jun 12, 2008 at 7:13 PM
Edited Jun 12, 2008 at 7:14 PM
Yeah, I had actually never touched this stuff before, I learned a little about how mod_rewrite for Apache works, and made some assumptions that this used a similar language. I also tried code snippets and things from some other similar rewriters to see if they worked, I guess that is how that one snuck in, I'll just omit it going forward.

Donation to charity sounds good, I'll check it out. :)
Jul 1, 2008 at 3:37 PM
Hi, first, this is a brilliant solution and was searching myself for it and fount it via google under the examples section.

But the 1.2.14b preview is not available any more and the 1.2.14 stable version is giving me the same results as jcsernik had with the previous versions, the %3 and %2 strings are missing.  Could someone supply me the 1.2.14b preview or fix the 1.2.14 stable with the fix in workitem 15185

Thanks in advance!
Coordinator
Jul 1, 2008 at 4:01 PM
Edited Jul 1, 2008 at 4:04 PM
Let me look,
I thought the fix 15185 was in v1.2.14 (latest stable).
I will verify that and get back to you.

Oh, Vipe, one other thing - can you try 1.2.15a ? 
It has very limited fixes beyond 1.2.14. 
Coordinator
Jul 1, 2008 at 4:12 PM

Vipe, I looked at v1.2.14 and it sure looks like the fix you want is in that release.
Are you sure you are experiencing the same thing as jcsernik? 

Can I see your rules file and your logfile?  I am specifically interested in the beginning of the logfile, where the version of the filter in use is logged, and also in the entries in the log for GenerateReplacementString() , where the problem referenced in 15185 was happening.

If you post your stuff, enclose them in <pre> tags so as not to lose formatting.

 

Jul 1, 2008 at 7:44 PM
Edited Jul 1, 2008 at 7:47 PM
Hi Cheeso, thanks for your swift reply.    Here are the results in the logfile with loglevel 5

Tue Jul 01 21:39:14 2008 - Initialize: Ionic ISAPI Rewriting Filter (IIRF) v1.2.14 final


Tue Jul 01 21:39:44 2008 - GetHeader_AutoFree: result '/_layouts/searchresults.aspx?k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - GetServerVariable_AutoFree: getting 'QUERY_STRING'
Tue Jul 01 21:39:44 2008 - GetServerVariable_AutoFree: 55 bytes
Tue Jul 01 21:39:44 2008 - GetServerVariable_AutoFree: result 'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - GetHeader_AutoFree: getting 'method'
Tue Jul 01 21:39:44 2008 - GetHeader_AutoFree: 5 bytes
Tue Jul 01 21:39:44 2008 - GetHeader_AutoFree: result 'POST'
Tue Jul 01 21:39:44 2008 - DoRewrites: New Url: '/_layouts/searchresults.aspx?k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - ApplyRules: depth=0
Tue Jul 01 21:39:44 2008 - ApplyRules: Rule 1 : 2 matches
Tue Jul 01 21:39:44 2008 - GetServerVariable: getting 'SERVER_PORT'
Tue Jul 01 21:39:44 2008 - GetServerVariable: 4 bytes
Tue Jul 01 21:39:44 2008 - GetServerVariable: result '443'
Tue Jul 01 21:39:44 2008 - ReplaceServerVariables: VariableName='SERVER_PORT' Value='443'
Tue Jul 01 21:39:44 2008 - ReplaceServerVariables: InputString='%{SERVER_PORT}' out='443'
Tue Jul 01 21:39:44 2008 - EvalCondition: ts1 '443'
Tue Jul 01 21:39:44 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl','(null)' ReplacePattern='443' vec=[[  [  0, 83, 1, 83] [] ] counts=2,0
Tue Jul 01 21:39:44 2008 - ApplyCaseConversion: before '443'
Tue Jul 01 21:39:44 2008 - ApplyCaseConversion: after  '443'
Tue Jul 01 21:39:44 2008 - GenerateReplacementString: result '443'
Tue Jul 01 21:39:44 2008 - EvalCondition: checking '443' against pattern '^443$'
Tue Jul 01 21:39:44 2008 - EvalCondition: match result: 1 (match)
Tue Jul 01 21:39:44 2008 - EvalCondition: Child is non NULL (parent= 0x01B22278) (child= 0x01B223A0)
Tue Jul 01 21:39:44 2008 - EvalCondition: Current condition evaluates to TRUE
Tue Jul 01 21:39:44 2008 - EvalCondition: Logical AND, ergo we evaluate the Child
Tue Jul 01 21:39:44 2008 - GetServerVariable: getting 'QUERY_STRING'
Tue Jul 01 21:39:44 2008 - GetServerVariable: 55 bytes
Tue Jul 01 21:39:44 2008 - GetServerVariable: result 'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - ReplaceServerVariables: VariableName='QUERY_STRING' Value='k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - ReplaceServerVariables: InputString='%{QUERY_STRING}' out='k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - EvalCondition: ts1 'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl','443' ReplacePattern='k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl' vec=[[  [  0, 83, 1, 83] [  0, 3] ] counts=2,1
Tue Jul 01 21:39:44 2008 - ApplyCaseConversion: before 'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - ApplyCaseConversion: after  'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - GenerateReplacementString: result 'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl'
Tue Jul 01 21:39:44 2008 - EvalCondition: checking 'k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl' against pattern '^((.*&)?u=http)s(.+)$'
Tue Jul 01 21:39:44 2008 - EvalCondition: match result: 4 (match)
Tue Jul 01 21:39:44 2008 - Cond : Child is NULL
Tue Jul 01 21:39:44 2008 - EvalConditionList: TRUE, Rule will apply
Tue Jul 01 21:39:44 2008 - ReplaceServerVariables: InputString='/_layouts/searchresults.aspx?%1%3' out='/_layouts/searchresults.aspx?%1%3'
Tue Jul 01 21:39:44 2008 - GenerateReplacementString: src='/_layouts/searchresults.aspx?k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl','k=iirf&u=https%3A%2F%2Ftesting%2Eoveralenaltijd%2Enl' ReplacePattern='/_layouts/searchresults.aspx?%1%3' vec=[[  [  0, 83, 1, 83] [  0, 54, 0, 13, 0, 7, 14, 54] ] counts=2,4
Tue Jul 01 21:39:44 2008 - ApplyCaseConversion: before '/_layouts/searchresults.aspx?%1%3'
Tue Jul 01 21:39:44 2008 - ApplyCaseConversion: after  '/_layouts/searchresults.aspx?%1%3'
Tue Jul 01 21:39:44 2008 - GenerateReplacementString: result '/_layouts/searchresults.aspx?%1%3'
Tue Jul 01 21:39:44 2008 - ApplyRules: Result (length 33): /_layouts/searchresults.aspx?%1%3
Tue Jul 01 21:39:44 2008 - ApplyRules: Last if Match
Tue Jul 01 21:39:44 2008 - ApplyRules: returning 1
Tue Jul 01 21:39:44 2008 - DoRewrites: Rewrite Url to: '/_layouts/searchresults.aspx?%1%3'
Tue Jul 01 21:39:44 2008 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue Jul 01 21:39:44 2008 - HttpFilterProc: SF_NOTIFY_URL_MAP
Tue Jul 01 21:39:44 2008 - HttpFilterProc: SF_NOTIFY_URL_MAP


RewriteLog  C:\Inetpub\wwwroot\iirfLog.out
RewriteLogLevel 5
RewriteFilterPriority HIGH
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{QUERY_STRING} ^((.*&)?u=http)s(.+)$
RewriteRule ^/(.*)$ /_layouts/searchresults.aspx?%1%3 [L]
Coordinator
Jul 2, 2008 at 6:45 AM

OK, yes, what you are seeing is most definitely a bug. Thanks for working through this with me. I tested your rules and input on my machine and had the same results.

You have some choices:

  1. get the updated v1.2.14 release - I've just patched it.
  2. or, get the v2.0a release  - it does not have this bug.
  3. Or, add this line to your ini file:
CondSubstringBackrefFlag %

I think the bug was introduced between the 1.2.14b interim release and the final release.  Whoops!
Anyway, you have some options now.

Let me know...

Jul 2, 2008 at 3:07 PM
Hey buddy,

    I had the same issue Vipe reported using the final of 1.2.14; I tested the current 1.2.15 release you have up, and it works as it should for this issue.
Jul 2, 2008 at 3:16 PM
Edited Jul 2, 2008 at 3:19 PM
Thanks allot , it works now , I downloaded the patched v1.2.14 release , I will ask my boss for a donation :)

I'm not going to try it again but yesterday the 2.0 preview release gave me the same result , not adding %1%3, just fyi
Coordinator
Jul 2, 2008 at 3:45 PM

GREAT

Thanks for the feedback, both of you.  Glad it's working now.