Apache directory icons?

Joined
Jan 28, 2011
Messages
240
Reaction score
0
Points
16
OK, my El Capitan Apache icon set didn't include icons for .ppt and .pptx. So in directory listings, those file names just showed up with a blank icon. I made a nice little p.gif icon file, and stuck it in /usr/share/httpd/icons. All the right permissions. Then in httpd.conf I put "AddIcon /usr/share/httpd/icons/p.gif .ppt .pptx".

Nothing happens. Those icons aren't called up in my directories. I still get blank icons for ppt and pptx files. What am I doing wrong??
 
Joined
Apr 16, 2016
Messages
1,096
Reaction score
51
Points
48
Location
CT
Your Mac's Specs
MacBook Air Mid-2012 / iMac Retina 5K Late-2014
You gave an absolute file path location and that won't work. Change your directive to:

Code:
AddIcon /icons/p.gif .ppt .pptx

In order for your icon to show up, the web server needs to create HTML code for the browser that will tell the browser where to locate the file, and the browser needs to be able to access the location that it was given. In the case of your original AddIcon statement, the web server was creating a location of "http://yourhost.domain.tld/usr/share/httpd/icons/p.gif" and that is CLEARLY not a valid path relative to the top-level directory for the web server.

Using my example above, your browser should be attempting to retrieve the file from "http://yourhost.domain.tld/icons/p.gif" which MAPS to the full path that you gave originally.
 
D

dlas

Guest
Thank you. In fact, I had a statement before that --

alias /icons/ "/usr/share/httpd/icons/"

That wasn't working. So I put in the whole address in the AddIcon statement. It seems that alias was originally misformatted, but I now have it right. So I changed the AddIcon statement as you advised. It STILL doesn't work.

Now what is a little peculiar is that when I restart Apache, I get a warning that that particular alias is a duplicate of one in /private/etc/apache2/extra/httpd-autoindex.conf. Um, whaaat? So I comment out one of those aliases, and I don't get the error, but it still doesn't work.

What the h*** is /private/etc/apache2/extra/httpd-autoindex.conf? That file seems to have it's own AddIcon statements.


My apologies about the new address. I am the original poster, but my account seems to have crapped out! I am told by Administrators that there is a problem being worked.
 
Joined
Apr 16, 2016
Messages
1,096
Reaction score
51
Points
48
Location
CT
Your Mac's Specs
MacBook Air Mid-2012 / iMac Retina 5K Late-2014
AddIcon statements are part of the Autoindex feature and configuration of Apache. What you've done is to add an Alias statement in your main configuration file that is an exact duplicate of one already contained in that feature-specific file.

Since I don't know how well-versed you are in Apache configuration, I'll lay out some basics here.

When you configure Apache, you have to tell it where the root of the web site is on disk. For Mac, this is /Library/WebServer/Documents. When you write the URL for your web site, it looks like this: http://host.domain.tld/ and your Apache daemon considers that the root of the -site-. Anything you put AFTER that in the URL would be either a document or a path to a document WITHIN the directory where the site starts. http://host.domain.tld/icons/ would translate to /Library/WebServer/Documents/icons on disk by default. The Alias statement is a way to 'redirect' the /icons/ subdirectory to somewhere else on disk without violating security. In this case, /usr/share/httpd/icons/

Make sense so far?

In this particular case, you're trying to get the browser to "pull" the correct image file to go with a particular file based on its extension. So, what needs to happen is that the browser needs to have the correct URL (http://host.domain.tld/icons/p.gif) and it needs to pick that file up from the correct place on disk (/usr/share/httpd/icons/p.gif). Since you already have the Alias command to redirect the subdirectory to right place on disk, you need to tell Apache to create the correct reference when building the file indexes.

If you are not getting proper results using the /icons/p.gif reference, try removing the leading "/" and create your AddIcon directive as follows:

Code:
AddIcon icons/p.gif .ppt .pptx

Another very useful tool in troubleshooting this is to actively watch the access and error logs while you are attempting to open the directory.

You can use

Code:
tail -f /var/log/apache2/access_log

and

Code:
tail -f /var/log/apache2/error_log

CTRL-C will break those. Be sure your browser cache is cleared between attempts to ensure that the browser will attempt to retrieve the data from the server.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top