{"id":41,"date":"2007-06-13T09:40:32","date_gmt":"2007-06-13T14:40:32","guid":{"rendered":"http:\/\/www.dannorris.com\/2007\/06\/13\/apache-http-server-redirects\/"},"modified":"2019-04-01T13:59:31","modified_gmt":"2019-04-01T13:59:31","slug":"apache-http-server-redirects","status":"publish","type":"post","link":"https:\/\/www.dannorris.com\/blog\/2007\/06\/13\/apache-http-server-redirects\/","title":{"rendered":"Apache HTTP server redirects"},"content":{"rendered":"<p>\t\t\t\tI&#8217;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&#8217;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&#8217;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&#8217;s custom domains into a name-based virtualhost with its own DocumentRoot, like this:<!--more--><br \/>\n<code><br \/>\n&lt;VirtualHost *:80&gt;<br \/>\nServerName www.mycustomdomain.com<br \/>\nDocumentRoot \"\/u01\/redirects\/mycustomdomain\"<br \/>\nDirectoryIndex index.html<br \/>\n&lt;\/VirtualHost&gt;<br \/>\n<\/code><br \/>\nThen, a single index.html file is placed in that DocumentRoot directory that contains this:<br \/>\n<code><br \/>\n&lt;html&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;Redirect&lt;\/title&gt;<br \/>\n&lt;META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=http:\/\/app.asphost.com\/portal\/page?_pageid=123,1&amp;_dad=portal&amp;_schema=PORTAL\"&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;\/html&gt;<br \/>\n<\/code><br \/>\n(Did I mention that this application is based on Oracle Portal?) That&#8217;s a lot of work when you have 40+ sites to manage. Of course the redirection destinations don&#8217;t change, but managing 40+ directories that each contain a single, customized file is Hard(tm).<\/p>\n<p>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:<br \/>\n<code><br \/>\n&lt;VirtualHost *:80&gt;<br \/>\nServerName www.mycustomdomain.com<br \/>\n<strong>RewriteEngine On<br \/>\nRewriteOptions inherit<br \/>\nRewriteRule ^\/$  \/portal\/page?_pageid=123,1&amp;_dad=portal&amp;_schema=PORTAL [R]<\/strong><br \/>\n&lt;\/VirtualHost&gt;<br \/>\n<\/code><br \/>\nAny request to http:\/\/www.mycustomdomain.com\/ is really a request to the website named www.mycustomdomain.com for a URI named &#8220;\/&#8221;. The RewriteRule above says that whenever someone requests &#8220;\/&#8221; from this website, you should redirect (that&#8217;s the [R] at the end of the line) them to the URI starting with \/portal&#8230;. Much easier, only a few configuration parameters to modify instead of creating a directory, a file, and editing the file.<\/p>\n<p>By the way, this will work on any Apache server that includes mod_rewrite&#8211;not just Oracle HTTP Server and certainly not just Oracle Portal URLs. In fact, I included a URI above (that didn&#8217;t include the hostname), but you could just as easily have included a complete URL with a protocol, host, port, and URI.<\/p>\n<p>Enjoy!\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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&#8217;t understand. The site is essentially an ASP that hosts their custom application for external customers. Each customer has registered &hellip; <a href=\"https:\/\/www.dannorris.com\/blog\/2007\/06\/13\/apache-http-server-redirects\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Apache HTTP server redirects&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,15,22],"tags":[],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-app-server","category-oracle","category-technical"],"_links":{"self":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":1,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":614,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts\/41\/revisions\/614"}],"wp:attachment":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}