Forum Moderators: coopster

Message Too Old, No Replies

redirect

         

lacaca

7:02 am on Jan 14, 2019 (gmt 0)



I have a redirect script that looks like this:

if ($m == "link1") {$link = "http://www.example.com";}
if ($m == "") {$link = "http://www.example.com";}
header("Location: $link");


Now, if a redirect link has no value for "m" there's that "empty" entry at the end and that works.

But, if there's a non-existing value, redirect does not work properly, and there's an error like "The page isn’t redirecting properly"

So, what kind of code would make non-existing "m" value to redirect like there's no value?

Thanks

robzilla

12:27 pm on Jan 14, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



if(!isset($m)) {
$link = 'http://www.example.com';
}

[php.net...]

Or, if the redirect is the same as when $m == "", then you could do:

if(empty($m)) {
$link = 'http://www.example.com';
}

[php.net...]

Welcome to WebmasterWorld!

lucy24

5:16 pm on Jan 14, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Or, in the alternative, set a default $link value at the beginning, and then set it to other values if-and-only-if your chosen conditions are fully met. (I suspect this is a personal-coding-style approach rather than an optimal-php approach.)