I%26#039;m attempting to insert a PHP IP redirect code into a website, but I continue to receive an error message. Currently the code works fine as a standalone .php file that routes users to one of two web addresses. I%26#039;d like to insert the code in the one of the web addresses index.html (index.php) so that the ip address in question is unable to view that file.
How do I go about inserting the code along with the sites original html tags?
------
%26lt;?
$host = getenv(%26quot;REMOTE_ADDR%26quot;);
if ($host == %26quot;204.231.25.10%26quot;) { $Redirect= %26quot;http://www.website.com/folder/%26quot;; }
else { $Redirect= %26quot;http://www.website.com/folder2/}
header (%26quot;Location: %26quot;.$Redirect)
?%26gt;
PHP Ip redirect code in html?
What is the error message you%26#039;re getting?
Anyway just an educated guess here, but you might want to put the rest of the page%26#039;s HTML inside a PHP conditional, so that it doesn%26#039;t execute if the redirection takes place... making it an if/elseif/else instead of just if/else.
PHP Ip redirect code in html?
%26lt;?php
$host = getenv(%26quot;REMOTE_ADDR%26quot;);
if ($host == %26quot;204.231.25.10%26quot;) { $redirect = %26quot;Location: http://www.google.com%26quot;; }
else { $redirect = %26quot;Location: http://www.yahoo.com%26quot;;}
header ($redirect)
?%26gt;
that will do it, just replace the urls with what u need, check out http://www.techroam.com
No comments:
Post a Comment