kYd Posted June 27, 2006 Share Posted June 27, 2006 How would I go about using a htaccess file to redirect people from a certain IP to another page on my site? Thanks Quote Link to comment Share on other sites More sharing options...
Snowy© Posted June 27, 2006 Share Posted June 27, 2006 http://www.webmasterworld.com/forum40/357.htm Helpful? Quote Link to comment Share on other sites More sharing options...
kYd Posted June 29, 2006 Author Share Posted June 29, 2006 Nope thanks any way. Tried it but didn't work. I really wan't to give these guys a re-direct to some goatse :twisted: Quote Link to comment Share on other sites More sharing options...
melodic Posted June 29, 2006 Share Posted June 29, 2006 so you have the ip for goatse then... : god knows how you obtained that Quote Link to comment Share on other sites More sharing options...
kYd Posted June 29, 2006 Author Share Posted June 29, 2006 lmao. im going to put some goatse and tubgirl pics on my site then when they come onto it direct them to that page Quote Link to comment Share on other sites More sharing options...
Dr Zaius Posted June 29, 2006 Share Posted June 29, 2006 I'm certainly no .htaccess guru, but I don't think it is capable of redirecting users based on their IP, although it can block users based on IP. I believe you may have to whip up a small php/cgi/etc script to do it. EDIT: Well I guess you could just block them and use custom error pages... Quote Link to comment Share on other sites More sharing options...
Sparda Posted June 29, 2006 Share Posted June 29, 2006 If the server you are using has PHP installed you can use the following codeto do URL redirects: <?php Header("Location: <URL gose here>"); ?> This will work even if the user has JavaScript disabled on they'er browser as it is part of the HTML 4.01 standered. Quote Link to comment Share on other sites More sharing options...
kYd Posted June 29, 2006 Author Share Posted June 29, 2006 Cheers Sparda, how would I go about using that with an IP address. If that don't work I guess Dr Zaius method should work. Thanks Quote Link to comment Share on other sites More sharing options...
Sparda Posted June 29, 2006 Share Posted June 29, 2006 What do you mean with an IP address? You could do some thing like this for example: <?php Header("Location: http://207.46.198.30/"); ?> With that code when ever some one visited the page you put that code on (even if they have JavaScript disabled as I have alredy explained) they will be redirected to Microsofts website. Quote Link to comment Share on other sites More sharing options...
sharpnyourteeth Posted June 29, 2006 Share Posted June 29, 2006 Cheers Sparda, how would I go about using that with an IP address.If that don't work I guess Dr Zaius method should work. Thanks Like Dr Zaius said, there is no way to redirect a certain IP with .htaccess, but what he suggested would work. And heres a solution in PHP to send certain IP addresses to a page. You can put this at the very top of any of your pages, say your index.php (if your host supports php of course) and if someone has the IP you specified they'll be redirected to the other page, but everyone else will see the normal page. <?php $address = $HTTP_SERVER_VARS["REMOTE_ADDR"]; if ($address == "xxx.xxx.xxx.xxx") { header("Location: goatse.html"); } ?> Quote Link to comment Share on other sites More sharing options...
kYd Posted June 29, 2006 Author Share Posted June 29, 2006 Cheers Sparda, how would I go about using that with an IP address.If that don't work I guess Dr Zaius method should work. Thanks Like Dr Zaius said, there is no way to redirect a certain IP with .htaccess, but what he suggested would work. And heres a solution in PHP to send certain IP addresses to a page. You can put this at the very top of any of your pages, say your index.php (if your host supports php of course) and if someone has the IP you specified they'll be redirected to the other page, but everyone else will see the normal page. <?php $address = $HTTP_SERVER_VARS["REMOTE_ADDR"]; if ($address == "xxx.xxx.xxx.xxx") { header("Location: goatse.html"); } ?> Thanks that worked! Let the evil rampage begin :twisted: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.