Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
742 views
in Technique[技术] by (71.8m points)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 .


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...