Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2013
    Posts
    31
    Thanks
    8
    Thanked 0 Times in 0 Posts

    htaccess direct certain ip to another page

    Hello

    trying to redirect a certain ip address to a different location on my site. so if they try to go to my homepage example.com, I want them to be redirected to example.com/weirdpage.php

    I have tried codes from many trustworthy sites but none work. when I tried it, it doesn't redirect. and yes, I did clear cookies.

    here is my complete htaccess code. can you tell me what i have to change about it to make it work?

    Code:
    # Always use www in the domain
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^([a-z.]+)?example\.com$ [NC]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .? http://www.%1example.com%{REQUEST_URI} [R=301,L]
    
    
    RewriteCond %{THE_REQUEST} ^.*\/index\.html?
    RewriteRule ^(.*)index\.html?$ http://www.example.com/$1 [R=301,L] 
    
    order allow,deny
    deny from 198.179.137.224
    deny from 198.179.137.225
    deny from 198.179.137.226
    deny from 198.179.137.228
    deny from 198.179.137.229
    deny from 198.179.137.230
    deny from 24.120.134.2
    deny from 198.179.137.231
    deny from 99.100.124.6
    deny from 198.179.137.247
    deny from 65.16.84.18
    deny from 198.179.137.232 
    allow from all
    
    
    RewriteCond %{REMOTE_ADDR} ^71\.252\.161\.50$
    RewriteCond %{REQUEST_URI} !/weirdpage.php
    RewriteRule ^(.*)$ /weirdpage.php [R,L]

  • #2
    New Coder seanmarkham's Avatar
    Join Date
    Dec 2011
    Location
    Lincolnshire, England
    Posts
    58
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Code:
    order deny,allow
    allow from all
    deny from 198.179.137.224
    deny from 198.179.137.225
    deny from 198.179.137.226
    deny from 198.179.137.228
    deny from 198.179.137.229
    deny from 198.179.137.230
    deny from 24.120.134.2
    deny from 198.179.137.231
    deny from 99.100.124.6
    deny from 198.179.137.247
    deny from 65.16.84.18
    deny from 198.179.137.232
    also try using full links for your RewriteRule at the bottom, so instead of /wierdpage.php use http://www.example.com/wierdpage.php

    IP redirect can be interesting unless you can guarantee a static IP, for example if the operator is using a manually configure IP rather than automatically selected.

    I don't know the purpose but if possible Redirect from a domain name would be a safer bet
    Last edited by seanmarkham; 09-22-2013 at 01:09 AM.
    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •