[php] Object not found! The requested URL was not found on this server. localhost

I have a typical set up A,M,P and i am just doing some testing on my localhost server for setting up a webpage. I'm a bit new to php and dynamic sites so I'm muddling my way though. So I am at an impasse here. Whenever I attempt to view the page in the browser and click on the links I get this error:

Object not found! The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. If you think this is a server error, please contact the webmaster. Error 404 localhost Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7

my url looks like this: http://localhost/test/content/home

here is the code for my index.php page and my nav.php page

first index.php

<?php
include('Config/setup.php');
?>
<?php
if(isset($_GET['page']) && $_GET['page'] == !'') {
    $pg = $_GET['page'];
} else {
    $pg = 'home';
}
#var_dump($pg);
#exit;
?>

<!DOCTYPE HTML>
<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">

    <title>FTS</title>
    <link href="css/Styles.css" rel="stylesheet" type="text/css">
</head>

<body>
<div class="header temp_Block">
    <?php include('templates/header.php');?>
</div>

<div class="main_nav temp_Block">
    <?php include('templates/main_nav.php');?>
</div>

<div class="main_Content temp_Block">
    <?php include('Content/'.$pg.'.php');?>
</div>

<div class="footer temp_Block">
    <?php include('templates/footer.php');?>
</div>
</body>
</html>

Here is my nav.php

<?php include('Config/setup.php')?>

 <a href="/test/content/home">home</a>
 <a href="/test/content/freestuff">free stuff</a>
 <a href="/test/content/aboutus">about us</a>
 <a href="/test/content/services">services</a>
 <a href="/test/content/Whatwedobetter">What we do better</a>

I thought this might be a permissions problem because /content/home.php is in a subfolder in xxamp/htdocs/test. But I'm not entirely sure. I could test this on a hosting site which I have but the 404 error makes me think it might be something with localhost and not with my code.

This question is related to php localhost http-status-code-404

The answer is


Simply my project wasn't in htdocs thats why it was showing me an this error make sure you put your project in HTdocs not in directory inside it


One thing I found out is that your folder holding your php/html files cannot be named the same name as the folder in your HTDOCS carrying your project.


write in file config

$config['base_url'] = 'http://localhost:8000/test/content/home/';

mostly this kind of error is caused by missing an .htaccess file in your root wordpress directory , however in order to check that , get in touch directly to the permalink structure and try to change your permalink and hit save , once you find the same error you should directly create an .htaccess file under wordpress root and make its first permissions to 777 , then refresh your site an click save change on your permalink , once your site continue to run correctly as you were expected , you should right away comeback to your .htaccess and change it to 644 in order to secure your site , i believe that this happened in most wordpress permalink settings , hopefully it would be helpful for anyone who meet this kind of issue .


I also had same error but with codeigniter application. I changed

  • my base URL in config.php to my localhost path

  • in htaccess I changed RewriteBase /"my folder name in htdocs"

    and I able to login to my application.

Hope it might help.


First check what your php error reports tells you. And define application wide root at the biginning of your index.php

define ('APPROOT', realpath(dirname(__FILE__)));

and then use it to include you files

include(APPROOT.'templates/header.php');

and so on... And to you have you .htaccess rewrite rule?


If the page you are visiting is index.php, then your url should look like

http://localhost/test/content/home/ OR http://localhost/test/content/home/index.php

not the way you specified - http://localhost/test/content/home

You are not specified your project as right way.

  • So run your XAMPP control panel then start the apache and MySQL
  • Then note the ports.
  • For Example PORT 80: then you type your browser url as localhost:80\ press enter now your php basic Config page is visible.
  • Then create any folder on xampp\htdocs\YourFloderName Then create php file then save it and go to browser then type it localhost\YourFolderName now it listed the files click the file and it runs.

Is the Config/setup.php file actually in /test/content/home/ or is in your document root? it is best to make all references relative to your document root.

include $_SERVER['DOCUMENT_ROOT'] . "Config/setup.php";

Your current code assumes that the location of setup.php is in /text/content/home/Config/setup.php, is this correct?


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to localhost

Xampp localhost/dashboard Set cookies for cross origin requests Invalid Host Header when ngrok tries to connect to React dev server How to turn on/off MySQL strict mode in localhost (xampp)? What is IPV6 for localhost and 0.0.0.0? How do I kill the process currently using a port on localhost in Windows? How to run html file on localhost? Can't access 127.0.0.1 Server http:/localhost:8080 requires a user name and a password. The server says: XDB How to solve ERR_CONNECTION_REFUSED when trying to connect to localhost running IISExpress - Error 502 (Cannot debug from Visual Studio)?

Examples related to http-status-code-404

Tomcat 404 error: The origin server did not find a current representation for the target resource or is not willing to disclose that one exists Vue-router redirect on page not found (404) Apache: The requested URL / was not found on this server. Apache Tomcat Servlet: Error 404 - The requested resource is not available Django, creating a custom 500/404 error page TOMCAT - HTTP Status 404 Object not found! The requested URL was not found on this server. localhost Getting 404 Not Found error while trying to use ErrorDocument Servlet returns "HTTP Status 404 The requested resource (/servlet) is not available" MIME types missing in IIS 7 for ASP.NET - 404.17