Disabling directory browsing with htaccess - .htaccess

Can some please clarify which of the following should be used for disabling directory browsing via htaccess?
Options -Indexes or Options All -Indexes
What is the difference between the two and in what instance should either be used?
Thank you.

Create a .htaccess file with the following:
Options -Indexes

Enabling directory browsing in Apache can be security issue - especially if used in production.
You can disable directory browsing by specifying Options -Indexes.
Note that it is better to do this in Apache configuration file / vhost files than in .htaccess.

Related

Codeigniter4 htaccess file wont work with options all - indexes

i want to setup a new codeigniter4 project.
I've upload all files into www.mydomain.com/sub1/sub2
The htaccess files into www.mydomain.com/sub1/sub2/public makes some trouble.
If i use the default file, i always get a "500 Internal Error"
So i check line by line. so i figure out that the line "Options All -Indexes" produce this error. If i delete it, i see the welcome page. But i think there is a reason why i should add this and related to this "Options +FollowSymlinks" too.
What can caused this problem. In my codeigniter3 projects i use
"DirectoryIndex index.php
Options -Indexes"
and it works fine. Codeigniter4 seems to need it into another way.
After hours of testing and trieing, i find a way (but i not really understand why).
Changing the htacess file in the public folder
from
Options All -Indexes
Options +FollowSymlinks
to this
Options -Indexes
Options SymLinksIfOwnerMatch
solved the problem and the codeigniter project is viewable. So maybe it could help someone.

Combining -Indexes and +MultiViews in .htaccess

I've disabled browsing directories (-Indexes) and enabled the option for users to visit pages with and without .html file extension (+MultiViews). Like this:
Options -Indexes +MultiViews
It seems that that is causing a 403 'Forbidden' error with this url:
example.com/blog
when there is a directory called blog and a a file blog.html.
How do allow access to /blog.html without the extension in the url, without allowing browsing access to /blog/?
You need to turn off directory slash on your server in order to access the file of the same name as directory.
Add the following line to your htaccess file
DirectorySlash off
See the official documentation of DirectorySlash on apache mod-dir page
https://httpd.apache.org/docs/2.4/mod/mod_dir.html

OpenShift Options +Indexes still do not work

When I place Options +Indexes in .htaccess I always get 404 instead of DirectoryListings. However this wasn't always possible now it should be. But I can't get it working.
I have a folder of images which I need to get listed. I'm using the perl-5.10 cartridge.
Options +Indexes is disabled on OpenShift due to security risks. It can not be enabled by the user.

WSGIPassAuthorization On directive in .htaccess

I am get issue with set WSGIPassAuthorization On directive in .htaccess.
any one can suggest how to add this variable to .htaccess ?
thank all so much.
You don't actually state what the specific error you get is when you try.
Has your Apache even been configured to allow use of .htaccess files?
Has your Apache even been configured to allow FileInfo overrides in .htaccess files?
AllowOverride FileInfo
Both would be required for WSGIPassAuthorization to work in a .htaccess file.
So please tell us what the error is you get in the browser and in the Apache error logs.
Indicate whether you have taken the steps above.

RewriteBase in Drupal not working

I just developed Drupal based website, instead of old one "custom" made.
Problem I'm facing is that root of website is not apache root. It is in directory:
/public_html/mydomain/htdocs/
Due to all of that, my links now looks like:
http://www.mydomain.com/mydomain/htdocs/php
http://www.mydomain.com/mydomain/htdocs/java
http://www.mydomain.com/mydomain/htdocs/jquery
Tried to change directive in Drupal's .htaccess file, with:
RewriteBase /mysite/htdocs
... but that made no changes to links.
Also, with previous website all links worked fine...
Can you tell me how to fix this directive.
Thank you in advance!
RewriteBase is not used for that purpose. You need to be editing the virtual host or vhost file. Find the vhost file in your apache configuration and change the DocumentRoot to your folder /public_html/mydmian/htdocs/ and just comment-out rewritebase.
RewriteBase is if your site is in a sub-folder of a "document root." What you have IS the document root.

Resources