PHP Developers Network
http://forums.devnetwork.net/

send specific visitor (IP) a special page?
http://forums.devnetwork.net/viewtopic.php?f=34&t=135823
Page 1 of 1

Author:  wvoyance [ Wed May 30, 2012 7:38 am ]
Post subject:  send specific visitor (IP) a special page?

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:

Author:  Celauran [ Wed May 30, 2012 8:08 am ]
Post subject:  Re: send specific visitor (IP) a special page?

Why not use a PHP header redirect?

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

Author:  wvoyance [ Wed May 30, 2012 10:18 am ]
Post subject:  Re: send specific visitor (IP) a special page?


Author:  Celauran [ Wed May 30, 2012 10:33 am ]
Post subject:  Re: send specific visitor (IP) a special page?

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.

Author:  wvoyance [ Thu May 31, 2012 6:44 am ]
Post subject:  Re: send specific visitor (IP) a special page?


Author:  Celauran [ Thu May 31, 2012 8:43 am ]
Post subject:  Re: send specific visitor (IP) a special page?

Well yes, of course. Wrap it in a conditional.

Author:  VladSun [ Fri Jun 08, 2012 9:34 am ]
Post subject:  Re: send specific visitor (IP) a special page?

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

Author:  pickle [ Fri Jun 08, 2012 9:50 am ]
Post subject:  Re: send specific visitor (IP) a special page?

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

Author:  Celauran [ Fri Jun 08, 2012 9:54 am ]
Post subject:  Re: send specific visitor (IP) a special page?

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.

Author:  wvoyance [ Fri Jun 08, 2012 7:43 pm ]
Post subject:  Re: send specific visitor (IP) a special page?

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

Author:  pickle [ Mon Jun 11, 2012 9:47 am ]
Post subject:  Re: send specific visitor (IP) a special page?

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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/