Jump to content

[SOLVED] I know I'm in the wrong place...


jonsjava

Recommended Posts

But this is my first question on this forum ever (go check, if you don't believe me :P )

I never check any other forum, so I'm posting it here, praying that you will help me anyways.

 

I need some cool .htaccess magic done.  I'm betting it's simple, but I usually just write a php script for this, but this time, it won't do.

 

and on to the question:

 

I need an .htaccess file that will generate a 404 not found error if the client isn't coming from a certian IP address. I don't need/want it to *look* like a 404, but to *be* a 404.

 

Please, don't move this, I beg you. I never check any other area on phpfreaks than PHP help, because I'm always helping, and don't want to miss a question I may be able to help in answering. (I need a life *sigh*)

Link to comment
https://forums.phpfreaks.com/topic/102369-solved-i-know-im-in-the-wrong-place/
Share on other sites

You can do it with PHP.

 

$not_allowed = array(IPs here);

if (in_array($not_allowed, $_SERVER['REMOTE_ADDR'])) //I think that's the right order.

{

 

header("HTTP/1.0 404 Not Found");

include("/var/www/html/site.domain.com/err/404.php");

exit();

}

 

Include the 404 document as appropriate.  That might not be your path, so change it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.