The coop is working fine for me, but I miss the benefits of 404 redirect traffic -- now if a non-existant HTML file is requested, the page returned is the error... Warning: file_get_contents(non_exist.html): failed to open stream: No such file or directory Going into the code I'm trying to think of an ELSE statement to add; essentially, if the file doesn't exist, redirect elsewhere. How do I do that? Here's the normal code. <?php if (!function_exists('file_get_contents')) { function file_get_contents($url) { $handle = fopen($url, 'r'); $string = fread($handle, 4096000); fclose($handle); return $string; } } Thank you to those who know PHP better than me.
I tried... <?php if (!function_exists('file_get_contents')) { function file_get_contents($url) { $handle = fopen($url, 'r'); $string = fread($handle, 4096000); fclose($handle); return $string; } else { header("Location: http://test.com"); } but that just sends the user on to test.com no matter what...
I realize that this isn't the sexiest of subjects, but there is a really good reason why I want to figure this out. Allow me to explain. 1. Some hosts are case sensitive; Index.html may not exist when index.html does exist. 2. I noticed that MSN has a nasty habit of caching Coop error pages because there are more references to a particular page in one case over another. 3. A malicious individual could toy with Coop members, testing to see if the host is case-sensitive -- if so, many valid pages could be cached with invalid information by pointing links to the opposite case filenames. Hopefully someone else out there sees this as I do; my knowledge of PHP is limited, but if there is an easier way to write the passthru.php to test for a file existing first, and on an error, skipping everything else, that'd be wonderful. Cygnus
Doesn't look like you are getting much help here. I thought everything after the "/" was case sensitive no matter what kind of web server you are running...I have never seen anything different. I am sure Shawn is going to want to be the one to make the changes to the PHP as far as the coop is concerned. Did you ever make that trip out to Sonoma?
Been learning some PHP in order to fix the problem on my end (good learning experience). Sonoma and Napa will be July 30-Aug 3...looking forward to it.
Not that there was really any interest in this, but I solved the problem at the mod_rewrite level so that only valid files are sent through to passthru.php in the first place. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR] RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*) /passthru.php?file=$1 </IfModule>
You can do that nice an clean with curl. There are controls for how long the call for the remote page should wait and such. There is an example here. It would be much cleaner and efficent code then the mod rewrite engine.