I am creating a URL shortener without a database that stores the information of each shortened URL in separate PHP files in the / urls directory, starting from the root directory.
I am creating the PHP script that deletes a URL, and because in each file a password is defined ( $password
) that serves to eliminate the URL (checking if the input and the file variable match).
I use the following code:
ob_start();
include "../urls/$alias.php";
ob_end_clean();
After it is reviewed, if for example the visitor has left a blank space, it is necessary to check the coincidence between the input
of the visitor and the variable that was defined in the file during the creation of this, by means of of the code indicated above, which has a redirection header
, causing that when I include it redirect me to the page that has been shortened.
The error is fairly easy to understand, but finding the solution (to avoid redirecting when you include it) is the problem. There are already several URLs that have been created and I refuse to have to edit them one by one, so I need to find a way to prevent this from happening.
Thanks for your answers.