Solved

Apache 404 and .htaccess files

Posted on 2007-03-28
4
1,557 Views
Last Modified: 2008-02-26
Hello All,

We have a bizzare problem which I hope somebody can shed some light on.  We have a content management system which we built, which uses the apache error diective and a .htaccess to control the 404 errors produced by apache.  Basically when a page / resource is not found, run a file and see if the user wants to create it.

Now the problem is that I believe the 404 errors are still produced by apache, so our rankings on google are going down the tubes.

My question is if we use the AccessFile Directive will apache still produce a 404 error even though we tell it to run another file?
0
Comment
Question by:seanostephens
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Steve Bink
ID: 18819697
AFAIK, the 404 would still be generated if you are allowing Apache to determine if the file exists or not.  What is the URL flow for a non-existant page being requested from your server?  For example, mine goes through mod_rewrite and sends all traffic to a PHP handler....the PHP file will determine where to send the user from there.

If you are simply replacing the standard 404 error page with one of your own designed to do work, that should not prevent the 404 from being generated...in fact, I would think that strategy would DEPEND on it being generated.  

Finally, you can download Firefox and an extension called "Tamper Data".  This will allow you to see what headers your web server is generating in real time.
0
 
LVL 15

Expert Comment

by:m1tk4
ID: 19705154
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup Zone:

  Accept: routinet {http:#18819697}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

m1tk4
Experts Exchange Cleanup Volunteer
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 19719231
Current follow-up:

As of my last writing, my strategy was to prevent a 404 from being generated at all.  This was because none of the pages on my site actually exist - they are dynamically generated by PHP/MySQL each time they are called - and I did not want a genuine page to show up with a 404 header.  Since then, I've rewritten the code to produce a 404 once the handler determines there is no page to build.  Below you'll find the relevant snippets from my server conf files and loader code.  

# From httpd.conf
# intercepts file requests that do not actually exist
# this is a rather slow method involving a sub-request
# using an ErrorDocument for 404 will likely be much quicker
# rewrite for db_build_loader.php
RewriteCond %{LA-U:REQUEST_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !^/db_build_loader.php$
RewriteCond %{QUERY_STRING} !^.*loadreq.*$
RewriteRule ^/(.+)\.(html?|php)$ /db_build_loader.php?loadreq=%{REQUEST_FILENAME} [QSA,NC,NS,L]

<?
// inside db_build_loader.php
// mod_rewrite lands here if the page does not exist
// if parse instructions are not in db, this is a real 404
if (!($pagerow = $result->fetch_assoc())) {
      error_log("Could not locate $path");
      error_log(print_r($_SERVER,1));
      header("HTTP/1.0 404 Not Found");
      header("location:/404.php");
      die();
}
?>
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

17 Experts available now in Live!

Get 1:1 Help Now