Feed aggregator
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.
Internet Archive Celebrates 1 Trillion Web Pages Archived
Read more of this story at Slashdot.
Fake Homebrew Google Ads Push Malware Onto macOS
Read more of this story at Slashdot.
YouTube's Likeness Detection Has Arrived To Help Stop AI Doppelgangers
Read more of this story at Slashdot.
US Investigates Waymo Robotaxis Over Safety Around School Buses
Read more of this story at Slashdot.
ISP Deceived Customers About Fiber Internet, German Court Finds
Read more of this story at Slashdot.
JetBrains Survey Declares PHP Declining, Then Says It Isn't
Read more of this story at Slashdot.
TikTok's New Policies Remove Promise To Notify Users Before Government Data Disclosure
Read more of this story at Slashdot.
Apple's Planned Foldable iPad With 18-inch Screen Hits Development Snags
Read more of this story at Slashdot.
KDE Plasma 6.5 Released
Read more of this story at Slashdot.
Amazon's DNS Problem Knocked Out Half the Web, Likely Costing Billions
Read more of this story at Slashdot.
France and Spain Call on EU To Uphold 2035 Combustion Engine Ban
Read more of this story at Slashdot.
