The ads have been running on my site for several months without a problem. I pretty sure this problem didnt exist until very recently but am not when things changed. I have code in place to display an 404 Error Page, so if someone goes to a page that doesnt exist eg http://www.mydomain/nosuchpage.html This used to redirect to the 404 Error Page without a problem. Now when I go to http://www.mydomain/nosuchpage.html I get the following error message Warning: file_get_contents(nosuchage.html): failed to open stream: No such file or directory in /home/bluerabb/public_html/passthru.php on line 13 If I open http://www.mydomain.com/404.html I see the page without a problem including the ads. Any ideas what is going wrong ? FYI Im running - ad_network_344.php .htaccess file is as follows: ErrorDocument 404 http://www.mydomain.com/404.html <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR] RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC] RewriteRule ^(.*) /passthru.php?file=$1 </IfModule>
The passthru.php method will not work if you are trying to redirect missing pages to a specific URL. I think this would work though as your passthru.php file (I haven't tried it myself). You might need to change the name of your ad_network file and change the URL you are trying to redirect to: <?php if (!function_exists('file_get_contents')) { function file_get_contents($url) { $handle = fopen($url, 'r'); $string = fread($handle, 4096000); fclose($handle); return $string; } } include ('ad_network.php'); $content = @file_get_contents(str_replace ('../', '', $_REQUEST['file'])); if ($content) { echo preg_replace ("/<\/body>/i", $ad_network . '</body>', $content); } else { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.mydomain.com/404.html"); } ?> PHP:
I tried this and ... Parse error: parse error, unexpected T_DNUMBER in mysitepath.com/passthru.php on line 5
however now I get this Warning: Cannot modify header information - headers already sent by (output started at mysitepath.com/passthru.php:1) in mysitepath.com/passthru.php on line 17 Warning: Cannot modify header information - headers already sent by (output started at /mysitepath.com/passthru.php:1) in /mysitepath.com/passthru.php on line 18
also appears that my problem is not related to the 404 page. I removed the custom 404 error page in the control panel went back to the original passthru.php and when selecting nonexisting page still get Warning: file_get_contents(html/cleaning___faclity.html): failed to open stream: No such file or directory in mysite.com/passthru.php on line 13
I found a solution here http://forums.digitalpoint.com/showpost.php?p=174165&postcount=6 using .htaccess to prevent files not found from going to passthru.php