I currently have a website running and a folder with some .php
files on it. My problem is if I type on the url corresponding to the file name, me and everybody can open and read everything that it is in that file. E.g.: www.mywebsite.com/folder/functions.php
Is there any way to prevent this issue?
When you go to your website root folder(www.mywebsite.com/) server most of the time loads index.php file. However if you don't have .htaccess with code similar to this
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteRule ^ index.php [L]
then it is possible for other user to have access to private config files, sometimes access to this kind of file may break you site.
Hope this helps
First of all, files like functions.php should be out of the root and websites' structure. If configured correctly, the server should not allow reading of functions.php and most probably this file would be blank in the browser.
If file or folder is not necessary for your website you just better remove it.
Probably you just will have to read more about web development and PHP. I have been in your position and I know that asking and try and error methods are slower actually.