RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.site\.ru$
RewriteCond %{HTTP_HOST} ^(.*)\.site\.ru$
RewriteRule ^(.*)$ http://site.ru/users.php?login=%1 [L,P]
function get_client_ip() {
$ipaddress = '';
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ipaddress = $_SERVER['REMOTE_ADDR'];
}
return $ipaddress;
}