Forum Moderators: phranque

Message Too Old, No Replies

Need help on IP based redirect

Contry based IP redirect

         

johnjames84

7:11 pm on May 21, 2010 (gmt 0)

10+ Year Member



Hi,

I want to redirect all Indian users accessing website(A) to a specific website(B). But, I want to allow only one Indian IP(122.165.xx.177) accessible to website(A). Below is my .htaccess, but i am not able to allow one one IP(122.165.xx.177) address to access website(A). can you please help.

Below is my code

#ErrorDocument 403 http://www.example.com
<Limit GET POST>
order Allow,Deny
Allow from 122.165.31.177
deny from 58.2.0.0/16
<snip>
deny from 221.134.128.0/17
deny from 221.135.0.0/16
</Limit>


Thanks
James

[edited by: jdMorgan at 7:27 pm (utc) on May 22, 2010]
[edit reason] Snipped code dump, switched to example.com [/edit]

jdMorgan

7:42 pm on May 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do NOT use a full URL as an errordocument, or you will absolutely make a mess of your search rankings.
Do NOT use your home page as an errodocument, or you will absolutely make a mess of your search rankings.

Write and use a custom error document for each error that you wish to handle, and refer to them as local filepaths in ErrorDocument directives.

Do NOT block access to robots.txt or to your custom 403 error document, or very unpleasant effects will ensue.

<Limit> is both a waste of time and a security risk here. Get rid of it unless you know why you must use it, and you have additional code to handle permissions for all of the other HTTP methods not included in your current <Limit> section.

Look up the "Order" directive and the "Allow from env=<varname>" format of the "Allow from" directive in mod_access and the SetEnvIf directive in mod_setenvif to clarify the following changes. Also look up the precise meaning of the <Limit> directive in Apache core, and notice that your code provided no protection against methods not specified in your <Limit> container -- such as "Delete" for example...

ErrorDocument 403 /403error.html
#
SetEnvif Request_URI "^/403error\.html$" neverdeny
SetEnvIf Request_URI "^/robots\.txt$" neverdeny
#
Order [b]Deny,Allow[/b]
#
Allow from 122.165.xx.177
Allow from env=neverdeny
#
Deny from 58.2.0.0/16
# <snip>
Deny from 122.165.31.0/24
# <snip>
Deny from 221.134.128.0/17
Deny from 221.135.0.0/16

Jim