I need Redirect from a specific page of the site to another - for everyone except the specified IP, they should open the correct page. Suppose there is a button, when you go to the page that opens only a specific IP. For others, another page opens, like "Sorry ..."
1 answer
Make it easier, write something like this in the index:
<?php $found = true; if ( $_SERVER['REQUEST_URI'] == '/' ) $page = 'landing'; else { $page = substr($_SERVER['REQUEST_URI'], 1); $vardu = $page; if ( !preg_match('/^[A-z0-9\/-]{3,16}$/', $page) ) $found = false; } if ($found) { if ( file_exists('/'.$page.'.php') ) include '/'.$page.'.php'; else $found = false; } if (!$found) { echo '404'; } ?> This is where the URL looks, and redirects to the page / page title. Add a rule like
echo $_SERVER['REMOTE_ADDR']; and then compare, if the resulting ip is equal to such an ip, then only the transition. Like this:
if ( $_SERVER['REQUEST_URI'] == '/' ) $page = 'landing'; else { $page = substr($_SERVER['REQUEST_URI'], 1); $vardu = $page; if ( !preg_match('/^[A-z0-9\/-]{3,16}$/', $page) ) $found = false; if (твои айпи != $_SERVER['REMOTE_ADDR']) $found = false; } - Site on zhume))) - Evgenias
|