Jump to content

404 PHP help


orbitalnets

Recommended Posts

Hi All,

I have made a super basic PHP wesite with all just php includes. Noting fancy.

http://orbitalnets.com/previews/masseerme/index.php?page=default

 

I have also made a index.php files that handles the url and 404 not found page.

 

This is the contents of the index.php file:

 

<?php

 

function get_include_contents($filename) {

  if (is_file($filename)) {

      ob_start();

      include $filename;

      $contents = ob_get_contents();

      ob_end_clean();

      return $contents;

  }

  return false;

}

 

$errormsg = get_include_contents('404.php');

$pagename = $_GET['page'];

$extension = "php";

 

if(file_exists("$pagename.$extension"))

{

include "$pagename.$extension";

}

elseif($pagename=="")

{

include "default.$extension";

}

else

{

echo "$errormsg";

}

?>

 

 

This is working just fine. But I notice a PHP error in the server log:

 

[Tue Mar 11 09:18:56 2008] [error] [client 82.95.50.149] PHP Notice:  Undefined index:  page in /usr/local/apache2/htdocs/previews/masseerme/index.php on line 15, referer: http://orbitalnets.com/previews/

 

Line 15 seems to be:  $pagename = $_GET['page'];

 

Other than the fact that this is working should I worry about this? How can I code this better? of correct?

I feel that this is not the correct way to do this. Please let me know.

 

Regards,

 

Dwayne

Link to comment
https://forums.phpfreaks.com/topic/95609-404-php-help/
Share on other sites

Ok now I see there si 2 diferent scenarios for 404 page.

 

1. http://orbitalnets.com/previews/masseerme/dfghdgh

 

and

 

2. http://orbitalnets.com/previews/masseerme/index.php?page=dfghdgh

 

The option number 2 shows the 404 page. But option number 1 shows just the text 404.php in de body.

For the option number one should I refer to the .htaccess file or could this be done also with php?

 

Let me know.

 

Regards,

 

Dwayne

Link to comment
https://forums.phpfreaks.com/topic/95609-404-php-help/#findComment-489480
Share on other sites

Ok. I expected the default internet explorer not found page rather than the text 404.php in the browser when typing a wrong url like this:

 

http://orbitalnets.com/previews/masseerme/dfghdgh instead of this http://orbitalnets.com/previews/masseerme/index.php=dfghdgh

 

 

Thanks I will refer the httpd.conf.

 

Regards,

 

Dwayne

Link to comment
https://forums.phpfreaks.com/topic/95609-404-php-help/#findComment-489493
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.