Manny Posted June 6, 2010 Share Posted June 6, 2010 I posted in the server section about some mod_rewrite's I was doing using the .htaccess file. I've set the rewrites up, but having an issue with my PHP redirects.I've included part of my code below. The first four work fine, but I don't understand why the last two aren't even attempting to redirect. // Server Redirectsif(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/","/games/predictionleague/index.php"))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague"); } if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?action=standings","/games/predictionleague/index.php?action=standings"))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/standings"); } if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?action=rules","/games/predictionleague/index.php?action=rules"))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/rules"); } if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?action=processing","/games/predictionleague/index.php?action=processing"))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/processing"); } if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?member=","/games/predictionleague/index.php?member="))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/member/" . $_GET['member'] . ""); } if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?matchday=","/games/predictionleague/index.php?matchday="))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/matchday/" . $_GET['matchday'] . ""); } Link to comment Share on other sites More sharing options...
real_illusions Posted June 7, 2010 Share Posted June 7, 2010 Since the last contain $_GET[] and the first 4 dont, I'm going to guess it something to do with that. As they're dynamic url's - this may have something to do with it.What error messages are you getting? Link to comment Share on other sites More sharing options...
Manny Posted June 7, 2010 Author Share Posted June 7, 2010 I took out the first four to see if the script would work but it still wasn't doing what I want it to.The main problem is, I'm not getting any error messages. So I don't really know what to do with it. Link to comment Share on other sites More sharing options...
real_illusions Posted June 7, 2010 Share Posted June 7, 2010 Add this:<?phperror_reporting(E_ALL); ?>to the top of your page. And then run it. Link to comment Share on other sites More sharing options...
Manny Posted June 7, 2010 Author Share Posted June 7, 2010 Still not getting any errors, which is a bit odd. Link to comment Share on other sites More sharing options...
real_illusions Posted June 7, 2010 Share Posted June 7, 2010 What happens then when you try to test the non-working redirects? Link to comment Share on other sites More sharing options...
Manny Posted June 7, 2010 Author Share Posted June 7, 2010 It just doesn't redirect and stays on the original page. The content displays but the object of having the 301 redirects is to redirect to a new URL which has been set in the .htaccess file. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2010 Share Posted June 7, 2010 If it's not redirecting then the if statement is not true, or you're already sending output which would stop the header and you've got error messages shut off. Assuming error messages are enabled, print the value you're checking in the if statement so you can tell what it is. Link to comment Share on other sites More sharing options...
Manny Posted June 7, 2010 Author Share Posted June 7, 2010 I've managed to sort it and, as always, it's something glaringly obvious. if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?member=" . $_GET['member'] . "","/games/predictionleague/index.php?member=" . $_GET['member'] . ""))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/member/" . $_GET['member'] . ""); }if(in_array($_SERVER['REQUEST_URI'],array("/games/predictionleague/?matchday=" . $_GET['matchday'] . "","/games/predictionleague/index.php?matchday=" . $_GET['matchday'] . ""))) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $siteURL . "/predictionleague/matchday/" . $_GET['matchday'] . ""); } In the actual if statement array, I hadn't got the $_GET variables. I've put them into the code and now the redirects work without a hitch. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.