Reputation: 8938
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:
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.
localhost
-stackoverflow
--foo.php
--bar.php
--humpday.php
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.
Upvotes: 3
Views: 12397
Reputation: 8938
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:
defaults write com.apple.Finder AppleShowAllFiles YES
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
.
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
Upvotes: 6
Reputation: 18908
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:
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:
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:
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.
Upvotes: 3