I’ve had the privilege (or substitute your own word) of working on quite a bit of Oracle Application Server configuration lately. The configuration I reviewed today brought to light another common configuration that I just don’t understand. The site is essentially an ASP that hosts their custom application for external customers. Each customer has registered their own domain name. So, when you hit www.mycustomdomain.com, it accesses the ASP’s website and redirects you to app.asphost.com/someurl. The mechanism that has been set up for this is to make each of the customer’s custom domains into a name-based virtualhost with its own DocumentRoot, like this:
Then, a single index.html file is placed in that DocumentRoot directory that contains this:
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://app.asphost.com/portal/page?_pageid=123,1&_dad=portal&_schema=PORTAL">
(Did I mention that this application is based on Oracle Portal?) That’s a lot of work when you have 40+ sites to manage. Of course the redirection destinations don’t change, but managing 40+ directories that each contain a single, customized file is Hard(tm).
Along comes me and sees yet another opportunity to do the same thing with less work (I love less work). So, remove the file and directory and, instead, replace a couple of lines in the VirtualHost definition so that it ultimately looks like this one:
RewriteRule ^/$ /portal/page?_pageid=123,1&_dad=portal&_schema=PORTAL [R]
Any request to http://www.mycustomdomain.com/ is really a request to the website named www.mycustomdomain.com for a URI named “/”. The RewriteRule above says that whenever someone requests “/” from this website, you should redirect (that’s the [R] at the end of the line) them to the URI starting with /portal…. Much easier, only a few configuration parameters to modify instead of creating a directory, a file, and editing the file.
By the way, this will work on any Apache server that includes mod_rewrite–not just Oracle HTTP Server and certainly not just Oracle Portal URLs. In fact, I included a URI above (that didn’t include the hostname), but you could just as easily have included a complete URL with a protocol, host, port, and URI.