Options -Indexes Code in .htaccess - apache

I just wanted to add a simple index.html to www re-direct command in an .htaccess file
When I opened the existing .htaccess file, the 'Options -Indexes' command was already in there. What exactly is this command? What is it instructing the search engines etc. to do?
Not a programmer, just an SEO manager. Thanks much, MB

The Indexes option sets whether you can "browse" the directory or not. If indexes is set to plus, and the directory has no index.html or index.php (of whatever) file, it will show the contents of the directory just like your filemanager would do. So if there are ten images in there, it simply shows them as a list with links to the actual image. You can click them and open them.

Related

display content of the folder as dir but only for specific folders

I have a generic site in /var/www/ and I did put my webpages in html, including sub folder that I am planning to use to store pdf and doc files.
Now; I would like that when a user go to mysite/files/docs or mysite/files/pdf, they can see the list of files, but even if they click on the parent link on that page, or if they type the url (like mysite/files); they won't see the list.
Is possible to enable the file display feature but only for certain folders? I did check Apache manual and it has options to set in httpd.conf file, although it was not really showing how to turn on or off specific folders; just how to turn it on and off globally.
I have .htaccess files that I use for settings, but even in that case; I can't find a way to display only some folder content and not others.
Create a .htaccess file in each directory files/docs and files/pdf
Then inside each .htaccess file add
Options +Indexes
That's it. It will display the files of only those 2 directories.

How can I get Apache to serve index files from subdirectories that have the same name as the subdirectory?

I was just asked to work on a terrible site that the client is running off IIS. I can't make changes to the live server so I attempted to install the site on my testing server running Apache.
The site's homepage is up and running but I cannot navigate to any subdirectories. The nav menu has links like /about-us/ -- however, there is no index.php file in the about-us directory. Instead there is a file named about-us.php.
If I was getting paid to fix the site up I would do the work to rename the files and/or links, but for now I just want to get this thing running so I can make my CSS and content edits and be done with it. I assume there is some easier way (using htaccess?) to dynamically tell Apache that, when directed to a subdirectory, look for /foo/foo.php instead of /foo/index.php -- right now all I get is a directory listing or permission denied if I turn indexing off.
I've been Googling around but can't find anything that looks like the same problem -- can one of you rewrite gurus please point me in the right direction?
The best approach for you is to set the appropiate DirectoryIndex for each directory as in:
<Directory /path/to/about-us>
DirectoryIndex about-us.php
</Directory>
You can also define a single "controller" in case there is no index page found, this is done like:
FallBackResource /index.php

Prevent Non-Existent Directories From Loading Wildcard Files

I am looking to prevent URLs for directories that don't exist from loading files with the same basename. For example http://domain.com/test/ is loading test.php. The test directory does not exist, but the file test.php does. I can see how this would be useful in most cases, but I am looking to disable it for my project.
I am on an Apache server. Is there a way to disable this option through an .htaccess file?
If there is an actual name for this type of feature, maybe "wildcard filename helper" or something like that, I'd like to know the official term too. Thanks!
This happens because MultiViews is enabled on the server.
If the apache configuration allows you to do so, you should be able to disable it by putting the following in .htaccess:
Options -MultiViews

Hiding files with apache

I've started using SCSS so in my css folder in my project, I have main.css and main.scss.
Is there any way I can prevent hide main.scss when I put this on my ftp? So it's still there, but not available for direct access?
Thanks!
Put this inside a .htaccess in the directory with the file you want to hide. Rename the file appropriately though (instead of yourfile.css).
<files yourfile.css>
deny from all
</files>
Of course you can also do this in your httpd.conf file aswell but the paths will need to be amended.
The problem with #GhostInTheSecureShell's answer is that this also denies access to the files, so the browser cannot download yourfile.css any more, which is probably not what you wanted.
To hide files (or directories) from index listings, but still allow access to them, use
IndexIgnore yourfile.css
in your .htaccess file.
This also works with patterns, so you can hide all css files using
IndexIgnore *.css
Or just name the files that you want to hide with a certain pattern, so, for example
IndexIgnore hide_me_*
will hide all files or directories that start with hide_me_.

How Come Everybody Can See My Private Files?

Sorry for the newbie question...
When I go to http://www.plans4boats.com/scripts/youtubeplayer/ in Google Chrome, I can see a full listing of the files there. What should I do if I don't want any old hacker to just come in and view/copy my source codes? Does it have something to do with htaccess?
I discovered that putting a blank index.html file in the folder helps for THAT folder, but it still leaves all subfolders vulnerable.
What should I google for more information on how to set up my server to prevent this?
Just set Options -Indexes for that particular directories either in an .htaccess file or a <Directory> or <Location> container.
What you need to do is turn of Directory Listing for your specific server. I don't know what server you're using so I can't walk you through it, but just google your server name and how to disable directory listing.
I created a file called .htaccess and put the following contents:
IndexIgnore /