Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #
  2. # Enable rewrite engine (requires mod_rewrite)
  3.  
  4. RewriteEngine On
  5. RewriteBase /
  6.  
  7. #
  8. # Set %{ENV:PROTO} variable, to allow rewrites to redirect with the
  9. # appropriate schema automatically (http or https).
  10.  
  11. RewriteCond %{HTTPS} =on
  12. RewriteRule ^ - [env=proto:https]
  13. RewriteCond %{HTTPS} !=on
  14. RewriteRule ^ - [env=proto:http]
  15.  
  16. #
  17. # Set %{ENV:ACCESSED_FROM}
  18. #
  19.  
  20. RewriteRule ^ - [env=accessed_from:outside]
  21.  
  22. RewriteCond %{REMOTE_HOST} ^81\.143\.232\.70$
  23. RewriteRule ^ - [env=accessed_from:office]
  24.  
  25. RewriteCond %{REMOTE_HOST} ^127\.0\.0\.1$ [OR]
  26. RewriteCond %{REMOTE_HOST} ^::1$ [OR]
  27. RewriteCond %{REMOTE_HOST} ^192\.168\.
  28. RewriteRule ^ - [env=accessed_from:local]
  29.  
  30. #
  31. # Redirect to domain if accessed from outside, no office, no local
  32.  
  33. RewriteCond %{ENV:ACCESSED_FROM} =outside
  34. RewriteRule .(.*)$ /%{ENV:ACCESSED_FROM} [R=301,L]
  35.  
  36. #
  37. # Rewrite to HTTPS
  38.  
  39. RewriteCond %{HTTPS} !=on
  40. RewriteCond %{ENV:ACCESSED_FROM} !=local
  41. RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/%{ENV:ACCESSED_FROM} [R=301,L]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement