I have a setup of Codeigniter in place with a controller called vendors. I also have a folder called vendors in the root directory of the project.
The problem is whenever I try calling www.example.com/vendors Codeigniter routes to the folder called vendors in the root directory and displays the file structure in the browser.
How can I fix this other than renaming either the controller or the folder.
Shouldn't Codeigniter be looking for a controller only under the controllers folder?
quote from OP's comment :
this happens on localhost (apache 2.4.27 and php 7.1.9 ), works fine on the production server.
After checking .htaccess and similar I found 2 solutions to hide a folder on localhost , but have it's containing files (eg images) accessible through a web-page.
the first is to add to your root .htacess file:
Options -Indexes
so it would look like this:
# DON'T FORGET TO CHANGE $config['index_page'] = '';
RewriteCond $1 !^(index\.php|assets|photos|videos|vendors|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
Options -Indexes
the second is to add an empty index.html file into that (vendors) folder.
The file structure is now hidden!
edit: actually, you see that codigniter folders have index.html files which look like this:
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.