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:

<VirtualHost *:80>
ServerName www.mycustomdomain.com
DocumentRoot "/u01/redirects/mycustomdomain"
DirectoryIndex index.html
</VirtualHost>

Then, a single index.html file is placed in that DocumentRoot directory that contains this:

<html>
<head>
<title>Redirect</title>
<META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://app.asphost.com/portal/page?_pageid=123,1&_dad=portal&_schema=PORTAL">
</head>
</html>

(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:

<VirtualHost *:80>
ServerName www.mycustomdomain.com
RewriteEngine On
RewriteOptions inherit
RewriteRule ^/$ /portal/page?_pageid=123,1&_dad=portal&_schema=PORTAL [R]

</VirtualHost>

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.

Enjoy!

  • Kueserc

    I want to do something similar but in my case a specific port is involved. So if I wanted the user to be able to enter machinex.domain.com I would want to reroute it to machinex:1234.domain.com/pls/dad/….

    In OAS the virtual host seems to be tied to a port. How does one go about eliminating that?

  • Kueserc

    I want to do something similar but in my case a specific port is involved. So if I wanted the user to be able to enter machinex.domain.com I would want to reroute it to machinex:1234.domain.com/pls/dad/….

    In OAS the virtual host seems to be tied to a port. How does one go about eliminating that?