Need help with htaccess

Discussion in 'General Scripting Chat' started by xgf666, Oct 1, 2012.

  1. xgf666

    xgf666 Junior Member

    Joined:
    Jan 18, 2011
    Messages:
    104
    Likes Received:
    6
    Location:
    At top of the Eiffel Tower
    Hi ! :amish:

    I need a simple htaccess code, I tried several generators but obviously there is something wrong with me. I just need a redirection script like:

    IP 127.0.0.1 127.0.0.2 go to index.html
    Else go to comingsoon.html

    Would someone be kind enought and write me this short code ?

    Thank you !!
     
  2. qrazy

    qrazy Senior Member

    Joined:
    Mar 19, 2012
    Messages:
    1,115
    Likes Received:
    1,726
    Location:
    Banana Republic
    try this..

    PHP:
      RewriteEngine on
    RewriteCond 
    %{REQUEST_URI} !/comingsoon.html
    RewriteCond %{REMOTE_HOST} !^123\.123\.100\.100
    RewriteRule 
    $ /comingsoon.html [R=302,L]
    This will redirect all the IP's to comingsoon.html and allow the ip mentioned (123.123.100.100) to the default index page
     
    • Thanks Thanks x 1
  3. xgf666

    xgf666 Junior Member

    Joined:
    Jan 18, 2011
    Messages:
    104
    Likes Received:
    6
    Location:
    At top of the Eiffel Tower
    Thanksss !!! If I want to add a second IP I had
    RewriteCond %{REMOTE_HOST} !^124\.124\.100\.100
    below the line ?
     
    Last edited: Oct 1, 2012
  4. qrazy

    qrazy Senior Member

    Joined:
    Mar 19, 2012
    Messages:
    1,115
    Likes Received:
    1,726
    Location:
    Banana Republic
    Yes you just need to add one more line to add new IP to be allowed i.e a new rewrite condition for every new IP.
     
  5. xgf666

    xgf666 Junior Member

    Joined:
    Jan 18, 2011
    Messages:
    104
    Likes Received:
    6
    Location:
    At top of the Eiffel Tower
    oups i'm afraid it didn't worked :(

    when I added the code with my IP I couldn't access any part of the site but the comingsoon page. and the comingsoon page was displayed as a blank page
     
    Last edited: Oct 1, 2012
  6. qrazy

    qrazy Senior Member

    Joined:
    Mar 19, 2012
    Messages:
    1,115
    Likes Received:
    1,726
    Location:
    Banana Republic
    Did you ensure you changed the IP in the script to your external IP?
     
  7. xgf666

    xgf666 Junior Member

    Joined:
    Jan 18, 2011
    Messages:
    104
    Likes Received:
    6
    Location:
    At top of the Eiffel Tower
    yep I used whatismyipadress dot com
     
  8. qrazy

    qrazy Senior Member

    Joined:
    Mar 19, 2012
    Messages:
    1,115
    Likes Received:
    1,726
    Location:
    Banana Republic
    You can replace the last line with this and try..

    RewriteRule \.html$ /comingsoon.html [R=302,L]
     
  9. xgf666

    xgf666 Junior Member

    Joined:
    Jan 18, 2011
    Messages:
    104
    Likes Received:
    6
    Location:
    At top of the Eiffel Tower
    Not working :(

    Here's the solution that worked for me


    RewriteEngine on
    RewriteCond %{REMOTE_HOST} !^123\.123\.123\.123
    RewriteCond %{REQUEST_URI} !/coming-soon\.html$
    RewriteRule (.*)$ /coming-soon.html [R=302,L]
     
    Last edited: Oct 3, 2012