T
T
Torento203452021-06-22 14:11:16
Apache HTTP Server
Torento20345, 2021-06-22 14:11:16

How to give priority to files in Apache and prohibit opening folders?

Good afternoon.
I ran into a problem that there is a
users folder in the root
and a pages folder in which there is a users.php file and also a users folder
There is a condition

if(file_exists('pages/'.$_GET['path'].'.php')) {
  include('pages/'.$_GET['path'].'.php');
}
else {
  include('404.php');
}

But for some reason, when you enter localhost / users - it opens the folder, and does not give users.php from the pages folder.
As a result, an open folder and you can climb there anywhere after.

How to close access to folders, that if a folder opens, then do not open it, but return 404.php and prioritize files over folders when requested in the query string.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question