Rachel Reeves targets GPs and lawyers in £2billion raid on middle classes: Chancellor ignores warnings economy could 'spiral out of control' with new budget plot - as UK debt hits £2.9TRILLION
The real cost of Andrew's Royal Lodge deal to the taxpayer as 'cast iron lease' makes it 'impossible' to evict him despite public outcry
UK data regulator defends decision not to investigate MoD Afghan data breach
The UK's data protection regulator declined to launch an investigation into a leak at the Ministry of Defence that risked the lives of thousands of Afghans connected with the British Armed Forces.…
Moment Irish police van is set alight as riots break out near Dublin asylum seeker hotel
NASA Opens SpaceX's Moon Lander Contract To Rivals Over Starship Delays
Read more of this story at Slashdot.
Nutritionist reveals the $2 food to eat everyday to lose weight without Ozempic
AMANDA PLATELL: The awkward questions about Beatrice and Eugenie's part in the Andrew saga are starting to stink. No one seems to want to talk about them - but I will
63 people killed in huge road crash after two buses 'attempt to overtake in opposite directions' in Uganda
Security guard with 'sadistic' plan to murder Holly Willoughby loses sentence appeal
JULIE BINDEL: At last the Met has woken from its Orwellian fever dream and given up the policing of hurt feelings - others must follow suit
The cheating wife, her fantasist lover and their plot to kill her husband... how 'loved-up' couple now face a lengthy time behind bars
CodeSOD: Forward Not Found
Anthony found this solution to handling 404 errors which um… probably shouldn't have been found.
function show_404($page = '') { $uri = $_SERVER['REQUEST_URI']; error_log("Caught 404: $uri"); $redirect_url = ""; switch($uri){ case "/SOMEURL": $redirect_url="http://www.SOMEWEBSITE.com/SOMEURL"; break; case "/SOMEOTHERURL": $redirect_url="http://www.SOMEWEBSITE.com/SOMEOTHERURL"; break; case "/YETANOTHERURL": $redirect_url="http://www.SOMEWEBSITE.com/YETANOTHERURL"; break; // ... THERE ARE 300 of these ... case "/MOREURLS": $redirect_url="http://www.SOMEWEBSITE.com/MOREURLS"; break; case "/EVENMOREURLS": $redirect_url="http://www.SOMEWEBSITE.com/EVENMOREURLS"; break; } if ($redirect_url){ Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: $redirect_url" ); } else { parent::show_404($page); } }Upon a 404 error, this code checks a switch statement. If the path portion (the REQUEST_URI) is in our switch, we redirect to a similar path on a different domain (I am only assuming it's a different domain; if it's the same domain, this is an entirely different class of WTF).
On the other hand, if we don't have an entry in our switch, we just show a 404 error.
I can see how this happened: someone migrated part of their site to a new domain, but didn't want to fix all the links (and can't fix all of people's bookmarks), so they wanted to automatically redirect the appropriate URLs. But here's the thing: this isn't the way to do it. In this particular case, the developers were using Code Igniter, a PHP framework for web apps, which has a routing engine; it would have been trivial to simply direct all the forwarded routes to a controller that just handles the redirects.
Or one of the many, many other options for redirecting users browsers that don't involve transforming a 404 into a 301 with a gigantic switch statement.