Solved

"Page not found" error, but the page exists!

Posted on 2011-09-14
15
224 Views
Last Modified: 2013-12-13
We have a website that was working perfectly fine yesterday, but for some reason one of the pages are returning a "page not found" error today. The php page does exist and I've not made any coding changes. I've contacted the webhost and they contend that no changes were made to the linux server. So i'm stumped, what reasons could there be for a 404 error when nothing seemingly has changed?

As a bit of background, our site is used for collecting and reporting KPIs. On one page users enter comments that will later be included in a generated PDF document.  This page's "Save" button calls a processing page ("save_individual_kpis_comments.php") to enter the comments into a database. It is at this point where the processing page is suddenly throwing a "page not found" error. As I've already said, nothing has changed on the coding side and I can see that this function was used yesterday to enter records into the relevant table. Funnily when I retry or type the URL into the browser  it does seem to run the PHP code and attempts to close the page after processing, however nothing is actually entered into the database.

I'm not the programmer who setup this website and my php knowledge is limited so trouble shooting has been difficult. Could anyone point me in the right direction here?
0
Comment
Question by:Silent_Killer
  • 4
  • 4
  • 3
  • +4
15 Comments
 
LVL 10

Expert Comment

by:stu215
Comment Utility
A couple of things to try:
-Try re-uploading the file to your server and specify "ascii" as the file transfer type.
-Check the permissions and the owner of the file on your linux server.

-Check to make sure the submission form is sending to the correct file.
( NOTE: some linux systems are case sensitive so the file name & path referred to by the submission form should match the exact relative the path to the destination )
0
 
LVL 3

Expert Comment

by:Duboux
Comment Utility
If you don't know much abt it, maybe just duplicate a working php file in the same folder.
And edit its contents by pasting the contents from the file that looks like is missing.
Then rename the not-working-file to something unique.
And rename the duplicated file you pasted the code in to the correct name.

This way you won't have to upload anything or play with permissions or transfer types ;)
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
Comment Utility
If neither of the above posts led to a solution, it would be helpful to know the O/S - Linux, Unix, Windows, something else?

Having said all that, my first suspect is a permissions problem as Stu pointed out.  Specifically, be sure that the file can be read by the web server software.  Compare the permissions of the PHP file in question with other PHP files in the same folder.  

If it's Linux or Unix, I would make sure that you haven't lost a symbolic link.  I don't know if your programmer used symbolic links, but I do.   (This is why I want to know the O/S.  There's little point in me offering Linux/Unix ideas if the server is Windows).

Another place I'd look, which I'll grant will be difficult for you, is the code itself.  It's possible (I don't think likely) but possible that the page is attempting to load a different page (than the page you expect) and the second page is the page that actually is missing or has incorrect permissions.

0
 

Author Comment

by:Silent_Killer
Comment Utility
To hmccurdy: It's Linux, symbolic links sound interesting and they may have been used, if you can give me an example of one, maybe?

We're using a webhosting company called WebHosting UK and have a shared Linux box with them. My thought is that it must be something on the server environment that has changed (upgrade of PHP version, some server variable change, ??) that is causing the problem and maybe we just need to rerun some "indexing" service to remap the site. I'm hesitant to start messing with the code 1stly because I'm not a proficient PHP programmer and secondly because the code was working fine on Tuesday and then this error yesterday without me having touched a thing on that site.

The webhost maintains nothing has changed. Now before I get into a (heated) debate with them about this, do you guys agree that it must be a server issue and not a coding one?

Thanks for all the posts by the way I'm definately going to check out the permissions suggestions, although again, I don't know who would have messed with it in the first place.

Many thanks for the help!
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
Comment Utility
Without knowing what all the software does, I can't be sure.  I think it's more likely that something happened on the computer.  However, I question if the web host has the capability to solve the problem even if it is their fault.

One thing to do, if you have shell access to the computer, is see when it was last booted.  The w command will give up the up time.  

$ w
08:19:16 up 2 days, 21:03,  6 users,  load average: 0.20, 0.24, 0.18

If it was rebooted between working and not working, then I think it's very likely it's a server problem.

Best I can do without seeing the code and that amount of work is likely beyond the role of EE.  (I suppose Ray could disagree but I'll let him do that if he does.)
0
 
LVL 3

Expert Comment

by:Duboux
Comment Utility
It sounds to me that you don't have ssh access and just have a hosting account.
If this is the case the only thing you quickly can do yourself is either upload the broken file again or what I suggeted earlier using either a ftp program or a web control panel.

if you do however have ssh access, u could run the following commands:
(assuming the code in your broken file is still correct)
assuming broken filename = broken.php
assuming a working filename = index.php
assuming you managed to cd into your folder

mv broken.php broken.old.php
cp index.php broken.php
cat broken.old.php > broken.php

It just creates a new broken.php file with the correct contents, and the same permissions as a working file.

I wouldn't waste energy on yelling at your host abt this. It could be anything, from bad disk sector to something else.
Just fix it yourself and have a smile back on ur face asap ;)
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
Comment Utility
Side comment related to Duboux's comment.  Years ago, we had the company website on a shared computer.  In this case, I did have ssh access and they included a regular Linux development env.  I could write CGI's in C.  (Years ago, I said.)  At one point, the compiler libraries became corrupted.  Clearly, without root access, nothing I could have done.  The ISP had no idea the library files were corrupted or how it happened.  But they were.  

They didn't know how to fix it and by then I stopped caring because we just happened to be migrating to a new server (that we controlled).  

Just saying lots of things can happen and the ISP doesn't necessarily have any idea it happened or why it happened or how to fix it.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Do you have a copy of phpinfo() output from the old days when everything was working?  You might want to compare that to phpinfo() today.  Look for things like magic quotes and register globals.  The default settings for these may have been changed.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_6630-Magic-Quotes-a-bad-idea-from-day-one.html
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_7317-Register-Globals-a-bad-idea-from-day-one.html

You might also want to look at the build date for the PHP installation to see if it is very recent.  Just a thought... ~Ray
0
 

Expert Comment

by:encodeme
Comment Utility
Why don't you fire up a html index page just to prove you're still talking with the server.
0
 

Author Comment

by:Silent_Killer
Comment Utility
Hi guys,

I've tried all your suggestions and created a new page from one that was working and just containing the phpinfo() statement to see if it can at least run that, however it still comes up with the "file not found" error. When I manually enter the URL the PHP info is displayed (unfortunately I don't have an older output to compare it againsts), so the problem is not with the content of the file. I've also checked the permissions and they are the same as all other executing scripts.

Could the problem be in the POST method from the calling page?
//<form method="post" action="save_report_comments.php" target="_blank">

This seems impossible to troubleshoot seeing as I can't even get it to go to a new page to display the values that are being posted.

Thanks for all the help and suggestions so far. If I can't get it fixed this week, I'll hire a freelance programmer and let you know the outcome.
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
Comment Utility
While I'm confident that I could solve this, I nominate Ray (not that you are taking nominations) as the freelance programmer.
0
 
LVL 3

Expert Comment

by:Duboux
Comment Utility
has the php software on your server been updated ?

anyway, that <form> line you posted wants to open the save_report_comments.php file which must be in the same directory.

maybe you can test a little, by changing the action to another page.
perhaps to a new page, that only has the following code: <?php echo "hi"; ?>
Then test by sumbitting that form, and see if u see the word "hi" on a blank page..
If so, then either:
- your save_report_comments.php file doesn't exist in the same folder
- your save_report_comments.php has no read-access for everyone
- your save_report_comments.php has a different ownership (maybe root or apache or w/e)
- there's a .htaccess file messing up your save_report_comments.php from showing
0
 
LVL 2

Expert Comment

by:eZov
Comment Utility
Have you checked .htaccess file. Is there any redirection set?
0
 

Accepted Solution

by:
Silent_Killer earned 0 total points
Comment Utility
Thanks for all comments & help to sort this issue.

- Redirection was correct.
- Htaccess was set properly
- URL was called correctly
- The form was posting to the correct php file.

After a lot of searching and tests the issue was found to be appearing whenever an = data was in the form POST. The HTTP POST that happens URL encodes all entries and then there is an additional encoding for =. This should be fine on most servers & server hosts BUT our host had the mod_security rule for the domain which threw an apache warning and diverted the page to 404.

This warning has been suppressed and the error is resolved. This was an error at apache level and the POST entry never got to the PHP level itself. Issue will only arise if you have set mod_security with warnings to show 404 page.

Following was the error in question.
[Wed Oct 19 10:48:07 2011] [client 82.13.67.210] ModSecurity: Access denied with code 406 (phase 2). Invalid UTF-8 encoding: invalid byte value in character at ARGS:previous_138. [offset "431"] [file "/usr/local/apache/conf/modsec2.user.conf"] [line "23"] [id "950801"] [msg "UTF8 Encoding Abuse Attack Attempt"] [severity "WARNING"] [hostname "www.domain.com"] [uri "/phpfile.php"] [unique_id "Tp6c11wwbgUAADDaFO8AAAA3"]
0
 

Author Closing Comment

by:Silent_Killer
Comment Utility
Solution provided by external consultant.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML Lists 3 29
How can I put a code without running my other code 4 18
Creating a slider 12 32
mysql left join sentence 7 19
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now