Want to redirect all visitors except for me

前端 未结 4 791
别跟我提以往
别跟我提以往 2021-02-01 07:24

Basically I\'m about to start work on a site and I\'d like something that I can add into my .htaccess file (or elsewhere) that\'ll work like this pseudo code: (my ip will be in

4条回答
  •  长情又很酷
    2021-02-01 08:11

    Here's the solution I ended up using, note that it is similar to VonC's except that his caused an infinite loop if you chose to redirect to the same domain.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
    RewriteCond %{REQUEST_URI} !/coming-soon\.html$ 
    RewriteRule .* http://www.andrewgjohnson.com/coming-soon.html [R=302,L]
    

    It should also be noted that 302 is a temporary move and should be used instead of nothing or 301.

提交回复
热议问题