Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # Enable rewrite engine (requires mod_rewrite)
- RewriteEngine On
- RewriteBase /
- #
- # Set %{ENV:PROTO} variable, to allow rewrites to redirect with the
- # appropriate schema automatically (http or https).
- RewriteCond %{HTTPS} =on
- RewriteRule ^ - [env=proto:https]
- RewriteCond %{HTTPS} !=on
- RewriteRule ^ - [env=proto:http]
- #
- # Set %{ENV:ACCESSED_FROM}
- #
- RewriteRule ^ - [env=accessed_from:outside]
- RewriteCond %{REMOTE_HOST} ^81\.143\.232\.70$
- RewriteRule ^ - [env=accessed_from:office]
- RewriteCond %{REMOTE_HOST} ^127\.0\.0\.1$ [OR]
- RewriteCond %{REMOTE_HOST} ^::1$ [OR]
- RewriteCond %{REMOTE_HOST} ^192\.168\.
- RewriteRule ^ - [env=accessed_from:local]
- #
- # Redirect to domain if accessed from outside, no office, no local
- RewriteCond %{ENV:ACCESSED_FROM} =outside
- RewriteRule .(.*)$ /%{ENV:ACCESSED_FROM} [R=301,L]
- #
- # Rewrite to HTTPS
- RewriteCond %{HTTPS} !=on
- RewriteCond %{ENV:ACCESSED_FROM} !=local
- RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/%{ENV:ACCESSED_FROM} [R=301,L]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement