Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect on deny | htaccess

How can I get the user to be redirected if their IP was matched on the deny of an IP address, e.g.

<Limit GET POST PUT>
  order allow,deny
  allow from all
  deny from {removed IP address}
</Limit>

I need them to be redirected to a specific website when they are denied from accessing.

Needing help with this..

like image 739
MacMac Avatar asked Nov 13 '10 00:11

MacMac


2 Answers

Setup a script to handle 403 errors by adding this line to your .htaccess:

ErrorDocument 403 /forbidden.php

Then handle the redirect in the script:

<?php
header('Location: http://google.com');

Or to keep it all in .htaccess you could do:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} 127.0.0.1
RewriteRule (.*) http://google.com [R]
like image 148
bradym Avatar answered Nov 04 '22 07:11

bradym


Simple solution using only htaccess

ErrorDocument 403 https:///google.com
Order Allow,Deny
Allow from 127.0.0.0/8
Allow from x.x.x.x
Allow from y.y.y.y
like image 30
César Araújo Avatar answered Nov 04 '22 09:11

César Araújo