dominoGuru.com

Your Development & Design Resource

Cleaner URLs via IBM Lotus Domino URL Substitution Rules and BASE HREF

This site - dominoGuru.com - runs on IBM Lotus Notes Domino... but you wouldn't know that from the URL. This quick tip highlights the technique of using Domino URL Substitution Rules for domain-specific Internet Site Documents to create cleaner URLs while still maintaining Domino NotesData Domino URL Command functionality.

Let's say your NotesDatabase is located on your Domino server in two subdirectories off of the root/Data directory:

/<dir1>/<dir2>/index.nsf

Our first step is to create an Internet Site Document for the incoming domain. Simple create a new Internet Site Document (after first making sure that your Domino server is setup to use Internet Site Documents...) with the following information:

Host names or addresses mapped to this site: Home URL:
dominoguru.com
www.dominoguru.com
/<dir1>/<dir2>/index.nsf/index.html

If you do nothing more than this, hitting dominoguru.com (or www.dominoguru.com) will work. It will consume the HTTP Request, and launch the NotesDatabase with the following URL address:

http://dominoguru.com/<dir1>/<dir2>/index.nsf/index.ht ml

Now, if you're using the standard Domino URL formatting, you can get away with making every URL-based link relative to the Domino-generated base URL. The problem with this technique however is that when moving between the Form/View/Page and the NotesDocument levels in the URL the Domino-generated base URL changes.

When you're on a Form/View/Page, the base URL is the NotesDatabase which means a call to image.gif actually points to:

http://server/<dir1>/<dir2>/index.nsf/image.gif

This breaks when you load a NotesDocument via URL, as the base URL shifts from the NotesDatabase to the View:

http://server/<dir1>/<dir2>/index.nsf/viewUNID/image.g if

Of course, you could create a relative URL to the given resource -- instead of image.gif use /image.gif -- but this actually makes the base URL the Domino Server... which is by design, as you could easily use the HTML subdirectory to store your common images, JavaScript frameworks, etc. and simply refer to them via /html/image.gif.

But to use a native resource to the NotesDatabase, you have to use some developer-Fu and add a Computed Text instance in front of the URL linked resource:

<img src="<Computed Text>image.gif" />

Where your Computed Text is the following:

"http://" + @GetHTTPHeader("HOST") + "/" + @WebDBName + "/"

Some Domino Developers have recommended adding a Base HREF tag in the HTML Header with the following formula:

<base href="<Computed Text>" />

... where the <Computed Text> Formula is the same Formula as the Computed Text example above.

Using this technique, you can simply refer to image.gif, or screen.css or FormName or ViewName or even ViewName/NotesDocument via URL, and the browser client will use the NotesDatabase as the root location.

... but this still gives you Domino-generated URLs.

And that's where the Internet Site Document Substitution Rules save the day!

IBM 
Lotus Notes Domino Internet Site Documents and Substitution Rules for 
dominoGuru.com

You simply create Substitution Rules for your Internet Site Document, making any inbound URL /* point to /<dir1>/<dir2>/index.nsf/*.

You then simplify your Base HREF:

"http://" + @GetHTTPHeader("HOST") + "/"

And now <img src="image.gif" /> from http://dominoguru.com actually points to http://dominoguru.com/ <dir1>/<dir2>/index.nsf/image.gif... but the URL address is simply http://dominoguru.com/image.gif!

This technique can be used when Domino is run in a ASP model (multiple customers/domains on a single Domino Server) or for those developers that don't have HTML directory access at the OS level, but need to add JavaScript and CSS Frameworks to your Domino apps while maintaining the framework directory structure.

This technique also allows you to move your NotesDatabase to another server or change the directory structure without breaking all of your search engine indexed and external hand-written URLs... aiding your Domino environment administration as well as your ability to maintain content availability.


About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of dominoGuru.com, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.



More from dominoGuru.com


dominoGuru.com is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, dominoGuru.com by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.