[TriLUG] URL/httpd.conf help?

Scott G. Hall ScottGHall at BellSouth.Net
Tue Dec 7 12:52:33 EST 2004


On 12/06/2004 12:57 PM Howard Boyd II wrote:
> Can someone please help me modify my httpd.conf file to modify
> incoming url requests? To access my site, users should enter:
> https://www.host.com/directory/file 
> 
> I want to configure the httpd.conf file such that if the user
> enters https://www.host.com they get the same page as if they
> entered https://www.host.com/directory/file 
> 

I do this same thing a quick easy way, but not through modifications to
the httpd.conf file.  I use a hosted site and don't have access to the
file itself.  But this works on any site, including my test bed at home:

You create a simple redirection script in place of the index.xxx file.
I use PHP because it is easy and can send headers before the 'html'
headers.  You can do the same thing in Perl.

------------code start------------
<?php # index.php

/* derive the true local absolute domain, including trailing slash */
$site_domain = $_SERVER['HTTP_HOST'];
         if (strtolower(substr($site_domain, 0, 4)) == 'www.') {
             $site_domain = substr($site_domain, 4, (strlen($site_domain) - 4));
         }
$absolute_url = 'http://' . $site_domain . dirname($_SERVER['PHP_SELF']);
         if (substr($absolute_url, (strlen($absolute_url) - 1), 1) != '/') {
             $absolute_url = $absolute_url . '/';
         }

/* Immediately transfer over to the welcome page */
header ('Location: ' . $absolute_url . 'simple/welcome.php');
exit();
?>
-------------code end-------------

If you need https, just remember to include that.  If this is your own
machine, make sure you have PHP enabled, and make sure the 'DirectoryIndex'
variable in your httpd.conf includes index.php, as in:

DirectoryIndex index.html index.htm index.html.var index.php index.php3 \ index.php4


-- 
Scott G. Hall
Raleigh, NC, USA
ScottGHall at BellSouth.Net



More information about the TriLUG mailing list