Results 1 to 5 of 5
  1. #1

    Question htaccess - Redirect all visitors except certain ip

    Did a search on the forum and google but could not find a solution for this reversed blocking

    I would like to redirect users who access the site from any IP address to be redirected like this:
    RedirectMatch /(.*)$ hxxp://extranet.domainname.com


    and have anyone from an IP address of 123.123.123.123 to just access/view the regular site, so not to be redirected.

    Any suggestions on how I can do this in my .htaccess file?
    Thanks

  2. #2
    Can you please more brief regarding redirection what you want to do...
    Back after a long time!

  3. #3
    Join Date
    Nov 2007
    Location
    Dallas, TX
    Posts
    8,946
    I'm assuming this is for an intranet / extranet setup?

    Might it be easier to just have an index.php that looks at the client IP and sends the appropriate content? You may not even have to redirect that way. If you want to go this PHP route, let me know, and I'll code a simple script for you (free).

    -Mike
    Mike G. - Limestone Networks - Account Specialist
    Cloud - Dedicated - Colocation - Premium Network - Passionate Support
    DDoS Protection Available - Reseller Program @LimestoneInc - 877.586.0555

  4. #4
    Mike:
    Thanks for your proposition/offer, but the whole site structure needs to be redirected including pdf's/video's and all different localization folders should have a their own redirection... and i think PHP is not an option with our current php backend....

    Technix:
    so actually i should be clearer... other example =)

    Redirect all users-->
    from --> to
    domain-example.com/de/* --> de.otherdomain.com/*
    domain-example.com/fr/* --> different.otherdomain.com/fr/*
    domain-example.com/other/* --> otherdomain.com/files/*

    BUT users from 123.123.123.123 should not be redirected

  5. #5
    Join Date
    Feb 2005
    Location
    Australia
    Posts
    5,842
    This will probably need some tweaking but it should give you a start. Test the blocks one at a time.
    Code:
    RewriteEngine On
    
    RewriteCond %{REMOTE_ADDR} !123.123.123.123
    RewriteCond %{REQUEST_URI} ^/other/
    RewriteRule (.*) http://otherdomainname.com/files/$1 [L]
    
    RewriteCond %{REMOTE_ADDR} !123.123.123.123
    RewriteCond %{REQUEST_URI} ^/(.*)/
    RewriteRule (.*) http://%1.domainname.com/$1 [L]
    Last edited by foobic; 02-25-2008 at 06:19 PM. Reason: reversed order of blocks
    Chris

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

Posting Permissions

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