apacheapache2apache2-module

How to print the description of file in colored font in apache2?


In Apache, we can add the description of file by adding the following(similar) in file /etc/apache2/mods-available:

AddDescription "your message" filepath with respect to your shared directory

But how can we set the font color of the "your message" in description. For example take a look of following image: enter image description here

I want the text under rectangular region with font color red. How can we do this ?


Solution

  • You can do this by adding HTML message with the apache AddDescription directive. Quote from the apache documentation:

    Descriptive text defined with AddDescription may contain HTML markup, such as tags and character entities. If the width of the description column should happen to truncate a tagged element (such as cutting off the end of a bolded phrase), the results may affect the rest of the directory listing.

    Example:

    AddDescription "<p style='color: red;'>My Message</p>" /path/to/file/or/directory
    

    This should work in apache 2.2 and 2.4. To read more about the mod_autoindex visit the apache docs: http://httpd.apache.org/docs/current/mod/mod_autoindex.html#adddescription