Skip to content
Advertisement

Checking the existing of a file by url inside native php router

I would like to know how could I check the existing of a file by a given url inside native php router (index.php) here is what I’ve tried :

JavaScript

Inside (index.php)

JavaScript

The page takes long time to output a message ‘Warning: get_headers(http://[website]/test): failed to open stream: HTTP request failed’ may be due to reccursion. How can I solve that without .htaccess file?

Advertisement

Answer

You can do this by using the file_exists command in PHP.See the following example:

JavaScript

__DIR__ here refers to the directory of the currently-executing script, so you will want to make all paths relevant to that.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement