+ 4
Path and directory things. Can you give me a hand please? (pure PHP)
I have a hosting (example.com) and I want to control the random paths access, and redirect to "home". Example: if someone access to "example.com/something" or "example.com/sdfdfdfsg", I want to redirect them to "example.com". I tried with a index.php into root directory using "$_SERVER['PHP_SELF']" and "$_SERVER['REQUEST_URI']", trying to detect the random path, but when I access to "example.com/something" or another, it says that doesn't exist (404, "Not found"); it's skipping my index.php - obviously - it search a directory. P.S.1: I use cpanel. Maybe it has a tool to help my problem, I don't really know. P.S.2: I use pure HTML5 and pure PHP 7; no CMS, no Frameworks. Can you give me a hand please?
2 odpowiedzi
+ 7
You have to setup custom error 404 page with .htaccess file.
In error 404 page you can show some fancy design like "Oops we can't find that page" or you can simply use header() and redirect user to index.php
How to do that?
https://www.google.com/amp/s/www.instructables.com/Custom-404-Error-Page-in-PHP/%3famp_page=true
+ 2
Searching how to use .htaccess right now. Maybe my solution.