• General stupid questions about 404 Errors and general PHP
    3 replies, posted
Hi guys, I used to code PHP a very long time ago when Habbo Retros were a big thing. Unfortunately Gmod made me take a blind eye to it all and now I have almost no knowledge at all. I was wondering how I would easily make a 404 error redirect to a certain image in only a certain directory. I'll be very thankful for your support. Would anyone also recommend PHP tutorials to get a decent knowledge again, especially in MySQL. Thank you in advance, Aaron
If you're trying to just make the "file not found" page be a specific image, that's a server thing, not PHP. Here's docs for every common web server, plus Microsoft's: Apache lighttpd nginx IIS As for tutorials, I don't have any to specifically recommend. I always just got by with the PHP.net documentation. I will specifically recommend against W3Schools, as their content is frequently out of date.
404 page generally depends on ur http server. Nginx: How To Configure Nginx to Use Custom Error Pages on Ubuntu 14.04.. Apache: How To Create a Custom 404 Page in Apache | DigitalOcean If you're routing all url to single index.php and if you're using a framework, you gotta read the docs on that. if you're making your own from scratch, then it would be the "default" case of your routing file. here's something i quickly glanced over https://phpdelusions.net/pdo seems like a pretty good tutorial for using mysql on php. using PDO, you might have to enable it on ur php config file. but PDO is the way to go if you're using php. also instead of a redirect to an image, why not just display the image on a 404?
For displaying an image: <?php     $img = file_get_contents('./image.png');     header('Content-type: image/png');     echo $img; For redirecting to an image: <?php     $image_path = '/path/to/image.png';     header('Location: ' . $image_path); These are obviously very simple and could probably be done a better way. But experiment around until you get something you like.
Sorry, you need to Log In to post a reply to this thread.