PHP help needed! - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Other (
https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (
https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: PHP help needed! (
/showthread.php?tid=252486)
PHP help needed! -
linuxthefish - 01.05.2011
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...
Re: PHP help needed! -
Sergei - 01.05.2011
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?
Re: PHP help needed! -
[WSF]ThA_Devil - 01.05.2011
Код:
<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
Re: PHP help needed! -
linuxthefish - 01.05.2011
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.
Re: PHP help needed! -
Calgon - 01.05.2011
Alternatively, you can use header() and forward them to the URL you want them to visit, i.e:
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.
Re: PHP help needed! -
mamorunl - 03.05.2011
I find using a .htaccess file works a bit better