« How to setup Gmail's smtp.gmail.com as the outgoing mail server on both Domino and on iOS | Main| How I added Textbox.io rich text editor to XPages »

How to redirect an URL in Domino and break the Domino-server's attempt to append any URL-parameter like "?OpenDocument" to the target URL!!

Tags: Configuration Lotus Domino
This is a story of something that I anticipated should take 5 minutes to fix. It turned out to take a couple of hours instead!

Very briefly - using the redirect web site rules, Domino will transfer any URL parameters (like ?OpenDocument, ?OpenForm etc) from the source URL-pattern to the target URL. If the target URL doesn't like OpenDocument very well, this ends up in an "HTTP Web Server: Invalid URL Exception". This article describes how I struggled worked to break this behaviour!

A picture named M2

Are you in a hurry? Skip right to trick 3 at the end of the article!

I all started with one of my sites that has evolved over some years. Below you see how the old "Bergan Vel" site looked.

A picture named M2
Not something to be extremely proud of! The new site looks better

A picture named M3

It all started back in 2001 and the site contained a calendar showing rentals amongst other things. Off course the site was exposed to Google, so people could find it

When my wife searched for "Barneskjær kalender" ("the calendar of Barneskjær") she got this in return from Google;

A picture named M4

The URL behind the scenes was this; http://www.berganvel.no/web/BerganVel.nsf/0/DFDC293AC3CED435C12570FB000264A2?OpenDocument

The result for my wife was that she saw the old and depreciated site.

What I want

The old URL should redirect to the new site http://www.berganvel.no instead.

A simple redirection web site rule should do it - but no!

I simply thought I could create a simple redirection rule in the Internet Sites section in my NAB, like this;

A picture named M5
A quick restart of the HTTP task with "restart task http" and voila, the redirect should be in place.

Since "http://www.berganvel.no" actually means "http://www.berganvel.no/web/bv.nsf/prod/index.htm" (specified in the internet site document it self) I was somewhat surprised to see that the old URLhttp://www.berganvel.no/web/BerganVel.nsf/0/DFDC293AC3CED435C12570FB000264A2?OpenDocument redirected to this URL "http://www.berganvel.no/web/bv.nsf/prod/index.htm?OpenDocument"...

Do you see the culprit? The redirection rule somehow appended the URL parameter "?OpenDocument" to the new URL too, and since that is an invalid URL, I got this error back :

Error 500
HTTP Web Server: Invalid URL Exception


And the behaviour has been discovered by IBM too ...

No matter what I tried, Domino continued to append the "?OpenDocument" to whatever I specified in the redirection document. It turns out that this is a known problem too, and IBM has described it in the technote "Domino web redirect appends OpenForm to non-Domino URLs" (http://www-01.ibm.com/support/docview.wss?uid=swg21624029);

A picture named M6

Trick 1: Create a simple LotusScript agent which redirects - didn't work either!

The suggested solution in the IBM technote above is to create a LotusScript agent which simply print "http://www.berganvel.no" combined with a web redirection rule pointing to the agent like this;

A picture named M7
Again, after a restart, the agent triggered OK, but the "?OpenDocument" from the original URL was still in place!!!

I thought perhaps I needed to do the redirect in a different way. Next step was therefore to create alternatives on how to redirect, with the hope that the other tricks removed the ?OpenDocument by themselves. Below you see the latest version of my agent;

A picture named M8
As you see, the original tricks with ...

Print "http://www.berganvel.no"

... dind't work. Neither did the other tricks with ...

Print |<SCRIPT>window.location.replace( 'http://www.berganvel.no')</SCRIPT>|

... or ...

Print |<meta http-equiv="Refresh" content="0;URL=http://www.berganvel.no">|

However, cool to see so many ways on how to redirect.

Common for all above was that Domino firmly appended ?OpenDocument to all target URLs.

Trick 2: Aaah - try to make something accepting the ?OpenDocument by default ... and then redirect! - Works? Nope!

The next trick was to follow the meta-tag way in a form with a name and URL field, and expose the documents in a view. First you see the form below;

A picture named M9
The basic trick here is to create the redirect in the "HTML Head Content" of the form with the formula;

"<meta http-equiv=\"Refresh\" content=\"0;URL=" + URL + "\">"

Using the URL like this ...


I do have a view with alias "go" in a database "redirect.nsf". The "berganvel"-part is the title from the form above, and with the "?OpenDocument" parameter I thought that would be OK. The agent redirects OK, but the target URL also got the ?OpenDocument-parameter too!!! In other words, very much the same as for the first trick!

Now I suddenly realize that this won't take 5 minutes anymore ...

The first IBM technote specified that there was a SPR with number  CJMS8D8RMT attached to the case . Searching for the SPR revealed only a couple of documents. The first was the very same technote, and the next was "LO57800: URL REDIRECT RULE TO REDIRECT TO A NON-DOMINO WEBSITE STILL CARRIES OVER THE ?OPENFORM FUNCTION" at http://www-01.ibm.com/support/docview.wss?uid=swg1LO57800. IBM describes the problem and concludes with "this is a suggestion, thanks but no thanks". The problem obviously still exists some 6-7 years after.

Trick 3: Create a document  plus view combination again - but now with referenced page-name - it works!!

Now I know that Domino is pretty darn determined to append "?OpenDocument" to whatever I try to redirect it to. I must somehow create a design-element/document combo that react to the ?OpenDocument in a natural way. First, a short recap is that the http://www.berganvel.no automatically resolves to http://www.berganvel.no/web/bv.nsf/prod/index.htm

Looking at the URL above, my currect take is to use a view  with the alias "prod", and then a document with the page name "index.htm". Since Domino appends ?OpenDocument automatically, I then can try to use the redirect-logic from trick 2.

Ok, first out is the form. The form is now in the target database, and looks like this;

A picture named M10

Note that I use a "Page name" instead, and if I see the berganvel-document, it looks like this;

A picture named M11
My thought is that the document "index.htm" would redirect to whatever the URL-field contains.

The next part of the trick is to create a view the alias "prod", It looks like this;

A picture named M12
I expose the documents with the form "fRedirect", and use the field "PageName", and ensures that it is sorted ascending. In the screen shot above you see the existing document with the page name content "index.htm".

So by using a web site rule redirection like this;

A picture named M13
I should be able to "attach" a combo of the original redirect, with a view and a document ... and the dreaded "?OpenDocument"

If I take a look at the target URL again ...


it consist of three parts. First is the result of the redirect from "http://www.berganvel.no" and comes from the specification of the internet site document itself, like this;

A picture named M14
The next part, prod, is the view element, and the final index.htm is the document from the prod-view.

Now, after a restart it turns out that this works!! Jiiha!

Hopefully this can be done better somehow, so please chime in if you know how! Otherwise, happy coding!


Gravatar Image1 - Robert, thanks for effort and sharing Emoticon

Post A Comment