Forum Moderators: coopster
if ($variable == "name\'s"){
header ("HTTP/1.1 301 moved permanently");
header ("Location: http://www.example.com/folder/names");
header ("Connection: close");
}
Live headers shows it gets a 301 status but it then bypasses the Location and gets caught in a check that I have to make sure num_rows is 1, so I needed to find how far it's actually getting so I added print "$query"; directly after the db call so I could see whats being passed.
With print "$query"; it all works perfect, the correct data loads and the correct URI is shown in the browser address, so, happy as larry I commented out the print "$query"; and it now gets missed completely, any ideas
EDIT: forgot to say, the Location address IS the same page the that the 301 is on
Connection ends when you press "Enter" twice.
The trick is that telnet shows everything (full response you can observe), whereas when trying to debug in browser you get either "redirected or not" result.
Hope that helps!
<?php
header("Location: http://www.example.com/"); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?>
OK I have 3 of these file names I would like to 301, they are all in a switch statement, am I better doing this
switch ( $variable ){
case "name\'s":
header ("HTTP/1.1 301 moved permanently");
header ("Location: http://www.example.com/folder/names");
exit;
break;
case "other\'s":
header ("HTTP/1.1 301 moved permanently");
header ("Location: http://www.example.com/folder/others");
exit;
break;
case "more-other\'s":
header ("HTTP/1.1 301 moved permanently");
header ("Location: http://www.example.com/folder/more-others");
exit;
break;
default:
$variable = "$variable";
}
is the above correct? or should I just run 3 seperate if statements?