I thought I'd share this tip as I just used it for the second time, so maybe you will one day.
Imagine you need to move a Domino database and its content to a different server. Chances are that the web address will change.
Let's say this database:
is moving to this new address:
How do you let users know? Do you setup URL Rewrite documents in the Domino Directory to auto-rewrite or redirect them as they come in? You could do, but an alternative is to simply display a page telling them it's moved, why it moved and that they should update their bookmarks accordingly.
You can then display a link for them to click to go to where they need to be. This tip describes a simple way to do that.
First, follow these steps:
- Copy the database to its new location.
- Delete all documents from the old database.
- Remove all Forms, Views etc from old database.
- Create a new Form called $$ReturnGeneralError in the old database.
It's this $$ReturnGeneralError form which does the magic:
Whenever a user visits any URL at the old address we can now show them a link to where they should be. The formula for the Computed Value you can see above is as follows:
oldSubDomain:= "server1"; newSubDomain:= "server2"; link:= "http"+@If(HTTPS="ON"; "s"; "") + "://" + @ReplaceSubstring(@LowerCase(Server_Name); oldSubDomain; newSubDomain) + @LowerCase(Path_Info); "<a href=\""+link+"\">"+link+"</a>"
The beauty of this trick is that it should work for absolutely any working Domino URL from the old database. including all of the following:
Because they will all be classed as 404/Errors the same form will be used to display the new location's link to the user. Simples!
This has also worked for me in the past when I've merged the content of one database with another. In that case rather than doing a replacement on the Server_Name field I did a replacement of the Path_Info string to update the file path to the new database.
When the web spiders next come crawling to index the old site they will get a lot of 404s. As I understand it, after a while it will stop indexing that content and forget it ever existed. Because we're providing the spider with a new working URL they should then index that instead. I know there are HTTP status codes (301) for doing this, but this done the same thing in a round-about fashion.