[SOLVED] Return Error 404 when a specified file is requested

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

[SOLVED] Return Error 404 when a specified file is requested

Post by tomfra »

In .htaccess, how I set that a given file which *does* exist should return a 404 Page Not Found Error when accessed through web browser but does not return any 404 error when accessed directly by a file in the same folder or on the same domain?

Thanks!

Tomas
Last edited by tomfra on Sat Jul 03, 2004 8:04 am, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can do this without .htaccess with something similar to the following example:

Code: Select all

<?php

if(!defined('IN_TOMFRA')) { header("HTTP/1.0 404 Not Found"); exit; }

?>
then just define IN_TOMFRA in a commonly used include or something..
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

Thanks, it works!

Tomas
Post Reply