Skip to content

Instantly share code, notes, and snippets.

@jorovipe97
Created December 21, 2020 15:58
Show Gist options
  • Select an option

  • Save jorovipe97/6b6f2b403adb34c35a1ef6c3313e7866 to your computer and use it in GitHub Desktop.

Select an option

Save jorovipe97/6b6f2b403adb34c35a1ef6c3313e7866 to your computer and use it in GitHub Desktop.

Revisions

  1. jorovipe97 created this gist Dec 21, 2020.
    15 changes: 15 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    # This redirects all users except me to a temporal website.
    # Inspired from: https://stackoverflow.com/questions/293285/want-to-redirect-all-visitors-except-for-me
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Redirect all except allowed IP
    # The HTTP:X-Forwarded-For is used when the site is behind a proxy or load balancer like CloudFlare, AWS Application Load Balancer, etc.
    # The used ip should be the public ip of your router, use a website like "whats my public ip" to know this.
    # In the case your site isn't behind proxies or load balancer, replace "HTTP:X-Forwarded-For" to "REMOTE_ADDR"
    RewriteCond %{HTTP:X-Forwarded-For} !^169\.169\.169\.169$

    # Temporary redirect to this other site.
    RewriteRule (.*) https://your-other-site.com/$1 [R=302, L]
    </IfModule>