Feed aggregator
OpenBSD 7.8 Released
Read more of this story at Slashdot.
Samsung Galaxy XR Is the First Android XR Headset
Read more of this story at Slashdot.
Jaguar Land Rover Hack Cost UK Economy an Estimated $2.5 Billion
Read more of this story at Slashdot.
Global Use of Coal Hit Record High in 2024
Read more of this story at Slashdot.
YouTube Will Help You Quit Watching Shorts
Read more of this story at Slashdot.
New Delhi Pollution Hits Five-Year High
Read more of this story at Slashdot.
Apple and Google Face Enforced Changes Over UK Smartphone Dominance
Read more of this story at Slashdot.
Reddit Sues Perplexity For Scraping Data To Train AI System
Read more of this story at Slashdot.
Meta Allows Deepfake of Irish Presidential Candidate To Spread for 12 Hours Before Removal
Read more of this story at Slashdot.
Uber Will Pay Drivers $4,000 To Switch To EVs
Read more of this story at Slashdot.
Google's Quantum Computer Makes a Big Technical Leap
Read more of this story at Slashdot.
Resistant Bacteria Are Advancing Faster Than Antibiotics
Read more of this story at Slashdot.
More Than 1,100 Public Figures Call for Ban on AI Superintelligence
Read more of this story at Slashdot.
Smart Beds Malfunctioned During AWS Outage
Read more of this story at Slashdot.
Rubbish IT Systems Cost the US At Least $40 Billion During Covid
Read more of this story at Slashdot.
GM To End Production of Electric Chevy Brightdrop Vans
Read more of this story at Slashdot.
NASA Opens SpaceX's Moon Lander Contract To Rivals Over Starship Delays
Read more of this story at Slashdot.
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.
[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!Automattic CEO Calls Tumblr His 'Biggest Failure' So Far
Read more of this story at Slashdot.
British Columbia to Permanently Ban New Crypto Mining Projects From Grid
Read more of this story at Slashdot.
