When typing "localhost" in the address bar, I want to see a directory of files/folders - apache

I recently installed XAMPP. I notice that when I type 'localhost' in the address bar of my browser, it shows a nice XAMPP welcome page. But I wish I could figure out how to show a directory of files and folders in my htdocs. I've seen this work on my old stack - 'parent directory', etc.
I've been digging around my httpd.conf file, and have found things on Google about AllowOverride, etc. Other sources say I should write a .htaccess file, but I can't get clarity on how to tweek my settings somehow to make this work.
Thanks!

Turn on your directory listing in apache configuration filehttpd.conf
For example if you projects are in /var/www/html, edit httpd.conf to add
<Directory /var/www/html >
Options Indexes FollowSymLinks
</Directory>
Following this, restart the httpd service

Related

.htaccess is not being read using XAMPP

I cant figure out why the .htaccess file is not being read. I am using XAMPP
Here is the httpd.conf file
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options None
AllowOverride All
Require all granted
</Directory>
I dont want content listing enabled except for one folder called photos.
so inside the photos directory inside htdocs- using notepad i created a .htaccess file and included
#Allow the listing of folder content
Options All
This did not work and the error log shows:
Cannot serve directory C:/xampp/htdocs/photos/: No matching DirectoryIndex (home.php,home.html,home.htm,index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
I also added rubbish to the beginning of the access file to see if it would reproduce an error but all it says is 403 forbidden.
Other things i tried was
#Allow the listing of folder content
Options Indexes
basically, for every folder there should be no content listing except for the photos folder which is why i created a .htaccess file and placed it inside the photo folders. (it must be a .htaccess)
any ideas why this is not working?
To anyone who comes across this needing help - I figured it out.
notepad was saving it as .htaccess.txt even after selecting 'All Files'
To fix this used brackets (you can use another other software like notepad++) and saved it under .htaccess and that worked.

MAMP just ONE virtual host not working

I wanted to start a (my first) wordpress project on my mac.
I run apache with MAMP, and wanted to make another (I allready have a few) virtual host for this particular project.
I added the host to my httpd.conf and etc/hosts file as i've done many times before.
When I browse to the url i've chosen I just end up in the directory that i've specified as root folder in my MAMP settings.
Apache seems to ignore the changes made in the httpd.conf file, but if I remove (rename) the httpd.conf file (to _httpd.conf) it apache doesn't start. so it looks like changes to this file are ignored, BUT if I put something wrong in the file apache doesn't start either...
this is what I put in the httpd.conf file to add a virtual host:
<VirtualHost *>
DocumentRoot "/Users/username/Sites/site_dir/"
ServerName local.sitename.com
<Directory "/Users/username/Sites/site_dir/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
can this have anything to do with WP?
greets,
R.
On Windows:
Try putting it in the conf/extras/httpd-vhosts.conf instead and try
where port 80 is whatever port you have apache running on (:80 by default on windows)
and try not to use .org .com or any ending common on the web in your server name/alias use if you are developing the project on your localhost use something like sitename.local instead.
On Mac:
Not sure how it would work
On Ubuntu 11.04:
I just:
Set up a different vhost file for each site inside of /etc/apache2/sites-available
Then enable the site via a2ensite or just make a copy to the file using cp to the sites-enabled folder (all this is done via the ssh or a terminal on mac)
I then reload and restart apache and wallah!
I'm having a similar problem on one of my ubuntu servers. I'm doing something that I've done several times but all of a sudden it doesn't work. Go figure, lol! Typo? Who knows, definitely scour the web, an answer is sure to surface.

wamp - www directory doesnt open new document root

I have changed default c:/wamp/www/ path to new directory c:/projectfolder/www/ in http.conf
The change has reflected, however when I click on the www directory in the wamp system tray (in windows 7), its still opening the old location c:/wamp/www/
I have restarted the service and exited wamp and relaunched and also rebooted the system but it still opens the old location.
Is this path taken from wamp settings somewhere instead of httpd.conf?
Note: Its not an issue for me except that I have to create a shortcut in explorer but I am running with another issue with flex, which I am not sure is anyway related to this.
Change the following part in the file C:\wamp\wampmanager.ini
[Menu.Left]
Type: item; Caption: "www directory"; Action: shellexecute; FileName: "c:/projectfolder/www/"; Glyph: 2
Here change the FileName to your new folder
Also change the following line in C:\wamp\scripts\config.inc.php
$wwwDir = 'c:/projectfolder/www';//To ur new project directory
If WAMP has default installation then you need to make changes into following file to change the directory of "www"
go to C:\wamp\bin\apache\Apache2.2.17\conf
Open httpd.conf file
Search for
DocumentRoot "c:/wamp/www/"
replace this line with your new directory
e.g DocumentRoot "d:/Sites/www/"
Then search for <Directory "c:/wamp/www/">
and replace with <Directory "d:/Sites/www/s">
Hope it will helps ..
Just as I had tried everything (including all the suggestions above and uninstalling and starting with a clean install), I was about to call the Exorcist. That's when it dawned on me that Virtual Hosts might be interfering with how URLs are mapped to files (a far fetch obviously, but all other possibilities had been exhausted).
Anyway, long story short, commenting out this line towards the bottom of httpd.conf did the magic for me.
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
I am not sure how this gotcha could be happening only to me. Alternatively, I don't get why this is not more prominently documented, since I expect that many, like me, are installing WAMP to have a quick LAMP environment on their windows machine. Wampserver 3.0.4 here...

Broken links in local Wordpress site

I have a wordpress site set up on a live server, and I have replicated the site locally by following these steps:
FTPed live files to local
Set up virtual host (dev.domain.com) to point at local version of site
Imported the db locally
changed wp-config.php to the correct local db settings
changed 'home' and siteurl' in db.wp_options to point to http://dev.domain.com (from http://www.domain.com)
Home page loads fine, /wp-admin all loads fine.
Problem is in links to pages:
Permalinks are set to point to post name: http://dev.example.com/sample-post/, just as on live server. However, locally, all links to posts are broken, and Apache (2.2.17) is responding with the following error: "The requested URL /sample-post/ was not found on this server."
I'm assuming I've missed a configuration step somewhere, though I've followed this process umpteen times in the past with no problems. The issue with this particular site is that the theme has been hacked with lots and lots of absolute paths entered, meaning setting up a dev site has required loads of code changes.
I'm not really sure how to further trouble shoot this, not completely understanding how Wordpress / Apache handles permalinks
Copy the .htaccess if you haven't already
I think that might be the problem
OK - sorted this, it was to do with mod_rewrite on apache.
To fix (this is for my install of Ubuntu 11.04):
first enable mod_rewrite in apache
sudo a2enmod rewrite
Then edit the relevant file in /etc/apache2/sites-available (could be 'default', or one specific to site):
sudo vi /etc/apache2/sites-available/site-file
Change AllowOverride directive for your site document root from None to All:
:
<Directory /var/www/site.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
That seems to have done it.

apache - how to override index of /icons?

I wasn't aware of this, and it is kind of funny; when you name a directory icons in the root of your host, then if you point your browser to host.com/icons, apache does not read from that directory and shows you a listing of Public Domain Icons.
I added an icons directory to the root and placed a key.png file in that directory, yet accessing that image results in 404. I tried to find if/where this has been documented and how it could be turned off. I found nothing. Could someone provide a pointer?
P.S. I am using XAMPP 1.7.3 which basically is a WAMP and has Apache 2.2.14
Edit
Aparently lots of live servers have this turned on and index of /icons could be seen lots of places.
Open this file: %XAMPP_PATH%\apache\conf\extra\httpd-autoindex.conf
and change :
Alias /icons/ "X:/xampp/apache/icons/"
<Directory "X:/xampp/apache/icons/">
to this:
Alias /icons/ "./icons/"
<Directory "./icons/">
Restart your Apache Server.
I'd assume that you have an alias within your httpd.conf.
I'm not familiar with XAMPP's config files or their location (google suggests it's probably in \xampp\apache\conf\httpd.conf) but I'd suggest you're looking for a line like the following:
Alias /icons/ /usr/local/apache/icons/
See http://httpd.apache.org/docs/current/mod/mod_alias.html for more info.
EDIT:
According to XMAPP site, you need to check \xampp\apache\conf\httpd.conf and the extra subfolder.
I would look in either your apache config file (\xampp\apache\conf\httpd.conf) or your .htaccess files and see if there is a redirect going on.
EDIT: I think Grhm is correct in that an Alias is in your config file somewhere, per the XAMPP site:
The main configuration file for Apache. It's including other files from the subdirectory "extra".
See if there is a directory called extra in the \xampp\apache\conf\ directory and then go through the files in there and see if that Alias is present.