Question

I recently purchased a new MacBook Pro (10.8 OS) and installed MAMP 3.0 (not MAMP-Pro) but I have been searching the web on how to display all files when viewing a folder within the htdocs directory such as: htdocs/stackoverflow VIA the browser (Chrome or Firefox). This is a feature that I do not have a problem with in Windows using either WAMP or XAMPP when navigating to the localhost/directory/contents. I do understand that localhost must be accessed through locahost:8888 or whatever port it has been modified to. I do not have an issue starting or stopping the MAMP server and everything is executable through NetBeans 8.0 when I set a .php file as the index:

enter image description here

So just to be clear, if I have a directory under htdocs (htdocs/foobar/) filled with several .php files I want to be able to view them in the sub-directory of htdocs instead of a blank browser (tested within Chrome and Firefox). I would imagine this is a security setting I am missing in the configuration? How would I enable, for local development, the ability to view all files, directories, and contents VIA the web browser? If it helps or may be an issue I am using NetBeans 8.0 as my IDE for PHP.

Windows:

localhost
-stackoverflow
--foo.php
--bar.php
--humpday.php

Mac:

localhost:8888
-stackoverflow
--empty in browser (chrome or Firefox)

I have searched to see if this a php.ini feature, MAMP 3 documentation has nothing on this, and Netbeans shows nothing per the search.

Was it helpful?

Solution

Ok after much research and the help from Kevbot and Matt Thompson I was able to figure out what to do and it is as followed:

You should enable all hidden files in Mac that are default hidden. To do this open a terminal (Finder > Applications > Utilities > Terminal) I originally referenced this site but it was wrong in regards to showing hidden files for OSX 10.8:

WRONG:

defaults write com.apple.Finder AppleShowAllFiles YES

RIGHT:

defaults write com.apple.finder AppleShowAllFiles YES

After doing so I held down the option + clicking Finder at the same time to prompt Relaunch of Finder.

enter image description here

You will need to navigate to MAMP (in this case MAMP 3.0 non-pro) in the Applications folder to MAMP > conf > apache > httpd.conf.

Open file in a text editor and search for Options Indexes. It was line 202 for me.

Change:

<Directory />
Options Indexes FollowSymLinks
AllowOveride None
</Directory>

TO:

<Directory />
Options Indexes FollowSymLinks
AllowOveride All
</Directory>

Create an .htaccess file in the desired directory and add:

Options +Indexes
IndexOptions +FancyIndexing

Launch/relaunch MAMP. Do note that if you have an index anything (.php, .html. .xhtml, etc. etc.) will show this instead of the directory listing

OTHER TIPS

Actual Answer:

You need to modify the .htaccess file in your root directory.

I was able to get this to work with no issues. In your .htaccess, add the following:

Options +Indexes
IndexOptions +FancyIndexing
DirectoryIndex somethingRandom.html

Here is what each line does:

  • Line 1 specifies to allow the indexing of files.
  • Line 2 tells the browser to display more information regarding the files
  • Line 3 tells the browser the default index file is not index.php or index.html. Just set the file to something that will never exist.

Old Answer:

There are several things you can do to configure MAMP.

You don't have to access MAMP with localhost:8888, you can access it with just localhost with the following changes. If you open the MAMP program, and select:

  1. Preferences
  2. Ports
  3. Set to default Apache and MySQL ports

Then, you can access your server through localhost in the web browser. Also, if you want to switch development folders (using a subfolder of htdocs as it's own site) you can configure those as well. Select the following from the MAMP program window:

  1. Preferences
  2. Apache
  3. Select (a folder inside of htdocs)

Now, when you access localhost in the browser, that folder will be your root folder until you change it back to htdocs.

And just to make sure, did you remember to "Start Servers?"

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top