Directory Alias Problems with Apache1.3/PHP4

From: Date: Wed, 25 Apr 2001 04:39:33 +0000
Subject: Directory Alias Problems with Apache1.3/PHP4
Groups: php.general 
Request: Send a blank email to php-general+get-50229@lists.php.net to get a copy of this message
Recently, I decided to convert my personal homepage to PHP. For simplicity, I do development on my home Windows 2000 box running Apache 1.3 and PHP 4, then FTP the code to the actual Linux-based web server (also running Apache/PHP 4). Since dealing with relative paths and included files in PHP is such a hassle, I decided to use absolute paths for everything (with the paths set in variables in my codebase.php so they're easy to change en masse later if I move my site). The problem is, I'm using a slightly different base directory structure on my development system than on the actual server. The URL of my homepage on the actual server is <http://www.paganpaths.org/~cfc/> (though technically stored in /usr/cfc/public_html/ or something to that effect), whereas on my local development system it's stored under <C:\webwork\home\>, which gets me a URL of <http://hotaru/home/>. The domain doesn't matter since I'm not using it in my paths, so the solution to this seemed simple enough. I created a directory alias in my httpd.conf: Alias /~cfc "C:/webwork/home/" This should allow me to access my local copy of my homepage at <http://hotaru/~cfc>; however, when I attempt to access it, I get a 500 Internal Server Error. Apache's error log says this about the problem: "Premature end of script headers: c:/program files/webserver/php4/php.exe". This leads me to believe that Apache's handling the directory alias, finding the index.phtml file, and then passing it to PHP, all as it should; but for some reason, PHP is choking on accessing the file in the aliased directory... I don't know why it isn't working, but my best guess is that Apache doesn't translate the URL before passing it to PHP, so it tells PHP to open "/~cfc/index.phtml", and since PHP ignores Apache's configuration/access directives, it doesn't know that "~cfc" = "home" and can't find the file. This would seem to fit the symptoms. I get an Error 500 when I try to open a PHP file that I know doesn't exist too, and if I use the non-aliased URL, everything works fine. So, my question is this... How can I get the aliased URL to work, without changing the real name of my local directory? And for that matter, since Unix servers use aliases for user web directories, am I going to run into this same problem when I upload it to the actual server? Is there some way around this? Any suggestions would be greatly appreciated; and they'll be appreciated even more if they're CC'd to me at <cfc@bigfoot.com>, since I check my email more often than I check this newsgroup ;) Thanks! -Corey

« previous php.general (#50229) next »