.htaccess tutorial

htaccess Elite


how to redirect to a html page for blocked ip address

Ask your mod_rewrite and Redirection questions here, and get answers!

how to redirect to a html page for blocked ip address

New postby neetika » 28 Nov 2006 07:28

Hi Friends,
After a long struggling I am successful in blocking file level access for a denyed/blocked IP address.

But when I did this
<files "testht.html">
Order allow,deny

Allow from All
deny from 192.168.0.102
</files>

This file(testht.html) is not shown to this ip adress user at all.all other files are visible.

But I want to redirect the request fron testht.html page to some other page for this blocked ip address.

All othe users should see all the files under a directory.except blocked ip address.

I don't know how to do this.
Kindly tell me step by step things to do changes in httpd.conf file.

or alternatively if it can be done through .htaccess file ,please tell me this also.

I tried but it says that one need to do some changes in httpd.conf file also to make .htaccess file works.






I will be highly obliged.

Thanks
Neetika
neetika
 
Posts: 7
Joined: 28 Nov 2006 06:59

New postby produke » 28 Nov 2006 07:37

In your web-root .htaccess file

Code: Select all
<Files testht.html>
Order allow,deny
Allow from All
deny from 192.168.0.102
ErrorDocument 403 http://www.redirect-here.com
</Files>


This will allow all users to access the file testht.html in all directories, but this will BLOCK any user with the IP address 192.168.0.102 and instead of showing them the testht.html page it will redirect to http://www.redirect-here.com.

Note that you can also use
Code: Select all
ErrorDocument 403 testht-failed.html
to redirect to a file on the local filesystem named testht-failed.html instead of redirecting to an external url.
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48

New postby neetika » 28 Nov 2006 08:01

hey I tried this but it is not redirecting me to that page

here is my code where I did changes to Directory directve and files
<Directory "C:/Program Files/apchtst">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.0/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#earlier it was None but now its limit
AllowOverride None

#
# Controls who can get stuff from this server.

Order allow,deny
allow from all

<files "testht.html">
Order allow,deny
Allow from All
deny from 192.168.0.101
ErrorDocument 403 errr.html
</files>


</Directory>


Note: I put my errr.html page under "C:/Program Files/apchtst"
so apchtst directory will be having 3 pages
testht.html
testht2.html
errr.html

I want to show errr.html page when a blocked ip addresses tries to see testht.html.

Not all allowed user showed be able to see this errr.html page.

Meanwhile I will try to put htis errr.html page in different forlder and tried to serve.

Thanks(your response gave me energy to do the things)
Neetika
neetika
 
Posts: 7
Joined: 28 Nov 2006 06:59

New postby produke » 04 Dec 2006 10:06

Since you are using Apache on windows, you should goto ApacheLounge for help. Its an awesome site and you will find your answers there.
User avatar
produke
 
Posts: 242
Joined: 25 Sep 2006 04:48


Return to Redirect or Rewrite Questions