404 Error Page

Discussion in 'Co-op Advertising Network' started by supahoopsa, Sep 6, 2005.

  1. #1
    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>
     
    supahoopsa, Sep 6, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    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:
     
    digitalpoint, Sep 6, 2005 IP
  3. supahoopsa

    supahoopsa Peon

    Messages:
    144
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    FANTASTIC!!!!

    That worked a treat.

    Thanks very much.

    David
     
    supahoopsa, Sep 7, 2005 IP
  4. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I tried this and ...
    Parse error: parse error, unexpected T_DNUMBER in mysitepath.com/passthru.php on line 5
     
    jazzylee77, Sep 8, 2005 IP
  5. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    uh..that was because I copied the line numbers too...
     
    jazzylee77, Sep 8, 2005 IP
  6. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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
     
    jazzylee77, Sep 8, 2005 IP
  7. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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
     
    jazzylee77, Sep 8, 2005 IP
  8. jazzylee77

    jazzylee77 Peon

    Messages:
    578
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #8
    jazzylee77, Sep 8, 2005 IP