Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ip = $_SERVER['REMOTE_ADDR'];
- $allowed = array('1.1.1.1','2.2.2.2'); // these are the IP's that are allowed to view the site.
- if (file_exists($maintenanceFile)) {
- if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
- // account for load balancer that passes client IP
- if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
- $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
- }
- if(empty($ip)) {
- $ip = $_SERVER['REMOTE_ADDR'];
- }
- // whitelist your ips
- $allowed = array();
- $allowed[]='WHITELIST.IP.ADDRESS.#1';
- $allowed[]='WHITELIST.IP.ADDRESS.#2';
- if (file_exists($maintenanceFile)) {
- if (file_exists($maintenanceFile) && !in_array($ip, $allowed)) {
- include_once dirname(__FILE__) . '/errors/503.php';
- exit;
- }
- }
- if (file_exists($maintenanceFile)) {
- include_once dirname(__FILE__) . '/errors/503.php';
- exit;
- }
- if (file_exists($maintenanceFile) && strpos($_SERVER['REQUEST_URI'], '/admin/') === false) {
- include_once dirname(__FILE__) . '/errors/503.php';
- exit;
- }
- RewriteEngine On
- ErrorDocument 503 /errors/503.php
- RewriteCond %{REMOTE_ADDR} !^4.3.2.1 [NC] #your IP
- RewriteCond %{REMOTE_ADDR} !^4.3.2.2 [NC] #other IP if needed
- RewriteCond %{REMOTE_ADDR} !^127.0.0.1 [NC] #localhost maybe needed depending on server setup
- RewriteCond %{REQUEST_URI} !^/errors/503.php
- RewriteCond %{REQUEST_URI} !^/media/
- RewriteCond %{REQUEST_URI} !^/images/
- RewriteCond %{REQUEST_URI} !^/css/
- RewriteCond %{REQUEST_URI} !^/js/
- RewriteCond %{REQUEST_URI} !^/skin/
- RewriteCond %{REQUEST_URI} !^/index.php
- RewriteCond %{REQUEST_URI} !^/admin #your admin path
- RewriteCond %{REQUEST_URI} !^/admin/
- RewriteRule ^(.*) http://www.yourwebsite.com/errors/503.php [L,R=503]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement