You are here: Re: Help: If isset query_string return 404 « PHP Programming Language « IT news, forums, messages
Re: Help: If isset query_string return 404

Posted by wd on 02/18/06 13:12

I just wanted to follow up on this thread. I finally got a chance to try
the recommended solutions and neither of the works.

I have an .htaccess file rewriting the URLs. So even though it looks like
the browser is visiting http://www.my_site.com/page1.html, PHP still
thinks the $_SERVER["QUERY_STRING"] is p=page1 (from
http://www.my_site.com/index.php?p=page1).

So every page except the home page ends up as a 404 not found error.

In the end, this solution worked -- PHP reads the URL and looks for a
question mark:

<?php
$url_string = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strstr($url_string, '?')) {
header("HTTP/1.0 404 Not Found");
echo <<<HTML
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
The requested URL was not found on this server.
</body>
</html>
HTML;
exit;
}
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация