How do I disable directory browsing?
Create an .htaccess file containing the following line:
Options -Indexes
That is one option. Another option is editing your apache configuration file.
In order to do so, you first need to open it with the command:
vim /etc/httpd/conf/httpd.conf
Then find the line: Options Indexes FollowSymLinks
Change that line to: Options FollowSymLinks
Lastly save and exit the file, and restart apache server with this command:
sudo service httpd restart
(You have a guide with screenshots here.)
How to disable directory indexing from apache2 when going to the server's root?
If it's only one directory that you want to protect from viewing contents, you can also just add an index.html or index.php that will show whenever someone browses to that directory.
Disable directory listing on apache; but access to individual files should be allowed
I really couldnt find a direct answer on internet ; even on apache documentation. Finally, could find the solution through few iterations; we need to use Options and the value should NOT contain Indexes.
<Directory "/usr/share/uploads">
Options Includes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
deny directory listing with htaccess
Options -Indexes should work to prevent directory listings.
If you are using a .htaccess file make sure you have at least the "allowoverride options" setting in your main apache config file.
How to restrict folder content listing in php
possible solutions:
- place a file index.html or index.php in the directory
- define in your httpd.conf
Options -Indexes
- place that line in .htaccess
personnally I prefer the 2nd line. There hardly ever is use for automatical listing of the files to a browsing visitor.
Stop Apache from serving content from apache root directory
You probably have the following directive in your httpd.conf:
Alias /error/ "/var/www/error/"
This just redirects all your error queries to /var/www/error (e.g. if you need www.example.com/error/README it would redirect me to one of the README in that director). Removing the alias should fix your problem.
If you are concerned about access to your other directories then I, as a complete newbie to apache, would recommend.
- Auditing your httpd.conf and removing any aliases that you don't need.
- Modifying your containers to have "Deny from all" and "AllowOverride None" in all of them.
- If you have selinux enabled, then remove the httpd security contexts from those directories.
Prevent access to files in a certain folder
Add this to the .htaccess
file:
order deny,allow
deny from all
Related Topics
Differentiate Between Exit and Session Timeout
Django on Apache Wtih Mod_Wsgi (Linux) - 403 Forbidden
Stop Being Root in the Middle of a Script That Was Run with Sudo
Replace Bash Variables in Template File
Usb Modem Is Echoing Back Wrong Characters
Multiple -A with Greater Than/Less Than Break Bash Script
Overhead of Supporting Floating Point Arithmetic Inside the Linux Kernel
How to Make a Bash String of Command with Redirect and Pipe
How to Scale Ejabberd Server MAChine on Centos to Handle 200 K Connections
Error Cl_Device_Not_Available When Calling Clcreatecontext (Intel Core2Duo, Intel Ocl Sdk 3.0 Beta)
Why Can't Cuda's Examples Makefile Find the Cuda Libraries
How to Solve "Bash: Ls: Command Not Found"
Gatttool Non-Interactive Mode --Char-Write
Find the Average of Fields in the Columns