1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Best way to keep visitors away during installation?

Discussion in 'Installation, Upgrade, and Import Support' started by RobParker, Apr 5, 2012.

  1. RobParker

    RobParker Well-Known Member

    I'm planning to move from VB to XF later today and wondered what the best way to keep visitors away during the installation?

    Can I just use a .htaccess access file to stop them accessing my site at all?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes, htaccess works. Or just turn off the forum.
     
  3. RobParker

    RobParker Well-Known Member

    I'm more worried what will happen as I'm deleting files and uploading the new ones, etc.

    If I wanted to send anyone visiting my site to say my twitter page is that possible and how would I exit the .htaccess file to do that?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    For example, this htaccess code will redirect everyone to twitter except for your IP address:

    Code:
    <IfModule mod_rewrite.c>
    	RewriteEngine On
    
    	RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$
    	RewriteRule ^.*$ http://www.twitter.com/ [R=302,L]
    </IfModule>
    
    Just enter your IP (which will not be redirected) and your twitter URL.
     
    aiman.h.kallaf and Edrondol like this.
  5. Carlos B

    Carlos B Member

    You can use this code replacing 127.0.0.1 with your IP address and example.com with any chosen link to redirect all users there. Just add it to the your index.php

    Code:
    <?php $allow = array("127.0.0.1");
     
    if(!in_array($_SERVER['REMOTE_ADDR'], $allow) && !in_array($_SERVER["HTTP_X_FORWARDED_FOR"], $allow)) {
     
        header("Location: http://www.example.com/");
     
        exit();
     
    } ?>
     
  6. KenX

    KenX Member

    How can I add multiple IP addresses?
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    <IfModule mod_rewrite.c>
    	RewriteEngine On
    
    	RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$
    	RewriteCond %{REMOTE_ADDR} !^11\.22\.33\.44$
    	RewriteCond %{REMOTE_ADDR} !^44\.33\.22\.11$
    	RewriteRule ^.*$ http://www.twitter.com/ [R=302,L]
    </IfModule>
    
     
    Brandon Sheley, EQnoble and Shelley like this.
  8. KenX

    KenX Member

    I used this but it is not redirecting to it.
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Works for me. Just tested it.

    Is that your entire .htaccess file? If you are adding it to XenForo's .htaccess file then you need to put it at the top.
     
  10. Carlos

    Carlos Well-Known Member

    Or just put xF into an unknown file and import it there.

    Done it twice already.
     

Share This Page