PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Dec 21, 2014 1:51 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed May 30, 2012 7:38 am 
Offline
Forum Contributor
User avatar

Joined: Tue Apr 17, 2012 8:24 pm
Posts: 135
I know I can block some specific IP by
order allow,deny
deny from 210.242.215.197/32
allow from all

But could I send them a specific page?
Those visitors are really nuscent I want to tell them do not come again. :roll:


Top
 Profile  
 
PostPosted: Wed May 30, 2012 8:08 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 3890
Location: Montreal, Canada
Why not use a PHP header redirect?

Syntax: [ Download ] [ Hide ]
header('Location: foo');

_________________
Stay on top of upgrades.
Supported PHP versions
No longer supported versions


Top
 Profile  
 
PostPosted: Wed May 30, 2012 10:18 am 
Offline
Forum Contributor
User avatar

Joined: Tue Apr 17, 2012 8:24 pm
Posts: 135
Celauran wrote:
Why not use a PHP header redirect?

Syntax: [ Download ] [ Hide ]
header('Location: foo');


Then, they can still access other pages, to my understanding.


Top
 Profile  
 
PostPosted: Wed May 30, 2012 10:33 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 3890
Location: Montreal, Canada
Not necessarily. You can easily put the blacklist code in one of your included files or your front controller, depending on how your site is set up. In either scenario, every request will see this code called and the undesirables redirected away. Unless, of course, they come in through a proxy of some sort.

_________________
Stay on top of upgrades.
Supported PHP versions
No longer supported versions


Top
 Profile  
 
PostPosted: Thu May 31, 2012 6:44 am 
Offline
Forum Contributor
User avatar

Joined: Tue Apr 17, 2012 8:24 pm
Posts: 135
Celauran wrote:
Why not use a PHP header redirect?

Syntax: [ Download ] [ Hide ]
header('Location: foo');


Could this command redirect only some visitor, not all?
I would like to redirect some visitor :P


Top
 Profile  
 
PostPosted: Thu May 31, 2012 8:43 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 3890
Location: Montreal, Canada
Well yes, of course. Wrap it in a conditional.

_________________
Stay on top of upgrades.
Supported PHP versions
No longer supported versions


Top
 Profile  
 
PostPosted: Fri Jun 08, 2012 9:34 am 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4294
Location: Sofia, Bulgaria
Syntax: [ Download ] [ Hide ]
header('Location: foo');
exit(); // !!!!

_________________
Image
http://openfmi.net/projects/flattc/ Linux is better :)


Top
 Profile  
 
PostPosted: Fri Jun 08, 2012 9:50 am 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6434
Location: 53.01N x 112.48W
I believe you can do it in mod_rewrite & therefore in your .htaccess file like your original post:

Syntax: [ Download ] [ Hide ]
  1. RewriteCond %{REMOTE_HOST} ^210\.242\.215\.197 
  2. RewriteRule .* /offline.php [R=302,L] 


I'm not entirely sure how to do it with IP ranges though

_________________
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.


Top
 Profile  
 
PostPosted: Fri Jun 08, 2012 9:54 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 3890
Location: Montreal, Canada
The problem with using .htaccess is that you'd need a new entry for each IP or CIDR value versus being able to query a database if you do it in PHP.

_________________
Stay on top of upgrades.
Supported PHP versions
No longer supported versions


Top
 Profile  
 
PostPosted: Fri Jun 08, 2012 7:43 pm 
Offline
Forum Contributor
User avatar

Joined: Tue Apr 17, 2012 8:24 pm
Posts: 135
Is every sub-directory which has an index.php need a .htaccess?

I put a .htaccess as the root directory but does not seems to be able to prevent access of some directories.
Put more .htaccess at those directories seems become o.k.
I found those directories seems all contain an index.php


Top
 Profile  
 
PostPosted: Mon Jun 11, 2012 9:47 am 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6434
Location: 53.01N x 112.48W
No, an .htaccess file is supposed to be applied to every subdirectory. I'm not sure if there are Apache directives that can be changed which make .htaccess only apply to the current directory, but I've always had them apply to ancestor directories.

_________________
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group