PHP help needed!
#1

I would like to redirect people to another page, if they are using the wrong URL to access my website.

E.G They visit "www.englishfreeroam.co.cc" and get redirected to "www.englishfreeroam.co.cc/EFR" and if they visit "linuxthefish.visualserver.org" they get redirected to "linuxthefish.visualserver.org/blog". I've tried to make something, but failed.

http://www.w3schools.com/php/php_if_else.asp - This could be used?
http://linuxthefish.visualserver.org/other/test.php - This shows it detecting the URL.
http://englishfreeroam.co.cc/other/test.php - This shows it detecting the URL.

PHP код:
<?php>
$domain $_SERVER['HTTP_HOST'];
if (
$domain=="www.englishfreeroam.co.cc")
    
//Redirect to site 1?
elseif ($domain=="linuxthefish.visualserver.org")
    
//redirect to site 2?
?>
I've NEVER used PHP like this before, so i'm only guessing...
Reply
#2

This is not PHP forum that's why you can't find any help.

If you only checked one of those forums you would find solution immediately, but I guess that's too hard for you?
Reply
#3

Код:
<html>
<head>
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>
Put it in middle of your PHP site... html + php works fine
Reply
#4

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
Код:
<html>
<head>
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>
<BODY>
Optional page text here.
</BODY>
</HTML>
Put it in middle of your PHP site... html + php works fine
Thanks for your answer, i've got it to work.
Reply
#5

Alternatively, you can use header() and forward them to the URL you want them to visit, i.e:

PHP код:
header("Location: http://some.thing.com/"); 
HTTP_HOST is probably not the best var to use either, I'm pretty sure there's a global var in $_SERVER that is a little less detailed.
Reply
#6

I find using a .htaccess file works a bit better
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)