Forum Moderators: phranque

Message Too Old, No Replies

Eliminating images from being sent to page not found

images, page not found, 404

         

davidsatz

4:02 pm on Apr 7, 2006 (gmt 0)

10+ Year Member



Hi,

I want to restrict when Apache 2.055 sends requests to the 404 page. I do not want requests for images and js files sent to the 404 page, but that seems to be what is happening. I only want images and js files that are not found logged to error.log.

Any idea how I can fix this?

TIA,
Dave

jdMorgan

4:25 pm on Apr 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can internally rewrite all of those 404'ed requests to a spsecific 404 error file for each file type.

The RewriteRule directive of mod_rewrite [httpd.apache.org] can be used to implement this.

For background information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

davidsatz

5:53 pm on Apr 7, 2006 (gmt 0)

10+ Year Member



thanks for the quick response. Hopefully, this is not an Apache 101 question, but I cannot find a post or an example of how to get Apache 2.055 to only forward requests for specific "page types" (HTML, PDF, HTM, CFM) to my 404 page. All the others I do not care about user going to 404 page (gif, swf, js, css).

I already fixed one issue on the CFM that deals with logging the page not found in a specific format.

I just switched from iPlanet and iPlanet could send 404s to my CFM 404 page.

TIA
Dave

davidsatz

8:24 pm on Apr 7, 2006 (gmt 0)

10+ Year Member



I meant "iPlanet could NOT send 404s to my CFM 404 page"

jdMorgan

12:29 am on Apr 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hopefully, this example will get you started:

# If not a request for html, htm, pdf, or cfm file
RewriteCond %{THE_REQUEST} !\.(html?¦pdf¦cfm)
# rewrite 404 error page request to alternate file (could even be blank)
RewriteRule ^local_URL-path_to_custom_404_page$ /local_path_to_alternate_404_page_for_images_etc [L]

Jim