sastro Posted April 28, 2010 Share Posted April 28, 2010 How to redirect visitor who visited my website via my dedicated IP? Link to comment https://forums.phpfreaks.com/topic/200068-prevent-visitor-access-via-ip/ Share on other sites More sharing options...
jdavidbakr Posted April 28, 2010 Share Posted April 28, 2010 Try this: <? if ($_SERVER['SERVER_NAME'] != 'www.example.com') { header("Location: http://www.example.com/"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/200068-prevent-visitor-access-via-ip/#findComment-1050095 Share on other sites More sharing options...
sastro Posted April 28, 2010 Author Share Posted April 28, 2010 Thx for replay but i want to redirect via .htaccess So if visitor come to http://111.1.1.1/ redirect to http://www.webiste.com/ http://111.1.1.1/page1.html redirect to http://www.webiste.com/page1.html Link to comment https://forums.phpfreaks.com/topic/200068-prevent-visitor-access-via-ip/#findComment-1050134 Share on other sites More sharing options...
JAY6390 Posted April 28, 2010 Share Posted April 28, 2010 In your .htaccess file put RewriteEngine on RewriteCond %{HTTP_HOST} ^1\.1\.1\.1$ RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] Link to comment https://forums.phpfreaks.com/topic/200068-prevent-visitor-access-via-ip/#findComment-1050176 Share on other sites More sharing options...
sastro Posted April 28, 2010 Author Share Posted April 28, 2010 In your .htaccess file put RewriteEngine on RewriteCond %{HTTP_HOST} ^1\.1\.1\.1$ RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] Works like a charm Thx Link to comment https://forums.phpfreaks.com/topic/200068-prevent-visitor-access-via-ip/#findComment-1050197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.