Forum Moderators: phranque
I've been trying to redirect IP's using htaccess to some directories and pages but to no avail.
I do it using 403 error page. The line below only allow ban IP to visit otherpage.html but they cannot browse to other pages or directories since they are banned. What is the method to allow those banned IP to be able to visit certain pages and directories?
ErrorDocument 403 /otherpage.html
SetEnvIf Request_URI "(otherpage\.html¦robots\.txt)$" allowit
Order Deny,Allow
Deny from 000.00.00
Deny from 0.0000.00
Allow from env=allowit
Your answer would be higly appreciated
Thanks
:)
Welcome to WebmasterWorld [webmasterworld.com]!
The usual method to redirect based on IP address or user-agent, or other HTTP-Request variables is to use Apache mod_rewrite. The RewriteCond directive can test %{REMOTE_ADDR} and cause RewriteRule to redirect specific URI request to specific files if the IP address matches or is within a specified range.
403-Forbidden error handling should not be used for any intermediate purposes, or unexpected and possibly damaging side-effects can occur.
Introduction to mod_rewrite [webmasterworld.com]
Jim
Thanks for the welcome jim. I have looked at the page. great resource!
btw, I've modified my htaccess to smething like this, this is to allow some pages and directories being able to be seen by banned IP's
ErrorDocument 403 /otherpage.html
SetEnvIf Request_URI "(alloweddir/other.html¦otherpage\.html¦robots\.txt)$" allowit
Order Deny,Allow
Deny from 000.00.00
Deny from 0.0000.00
Allow from env=allowit
is this method correct?
Thanks :)
I banned the IP from the root directory using this code in htaccess
ErrorDocument 403 /otherpage.html
SetEnvIf Request_URI "(otherpage\.html¦robots\.txt)$" allowit
Order Deny,Allow
Deny from 000.00.00
Deny from 0.0000.00
Allow from env=allowit
then in the subectories where I would like the banned IP's also being able to see the page and sub directories, I would put another htaccess file which would allow all IP's
<Limit GET>
order allow,deny
allow from all
</Limit>
would this method will works?
Thanks
Basically I want some IP redirected to certain page and being able to access view images from the page which is located in another directory (in this case /imagedir/subdir/)
This line seems not working either :(
SetEnvIf Request_URI "(allowed\.html¦robots\.txt)$" allowpage
SetEnvIf SPECIAL_PATH "(/imagedir/subdir/)$" allowdir
Order Deny,Allow
Deny from 202.146.241
Deny from 61.94.8.190
Allow from env=allowpage
Allow from env=allowdir
What's the correct way to do it?
This code
SetEnvIf Referer "/images/$" allowdir You may want to try:
SetEnvIf Referer "http://www\.example\.com/images/" allowdir Jim
The line below only allow ban IP to visit otherpage.html but they cannot browse to other pages or directories since they are banned. What is the method to allow those banned IP to be able to visit certain pages and directories?
.htaccess in / directory
---------------------------------
ErrorDocument 403 /errorpages/403.html
order allow,deny
allow from all
deny from 1.2.3.4
deny from 5.6.7.8
.htaccess in errorpages directory
-----------------------------------
order deny,allow
allow from all