Home > front end >  Serve static HTML files in Apache
Serve static HTML files in Apache

Time:06-17

I have documentation for an application that consists of a number of static HTML files.

I created a Docker image to serve these files which works, but it has a few issues.

  • The "default" web page is default.html, rather than index.html. How do I make default.html the "default" web page?

  • The name of the linked files in a given HTML has a difference case than the file itself. For example, the link is viewlist.html while the file's actual name is ViewList.html. Is there a way to ignore case?

  • It might be helpful just to list the files' names. Is there a way to enable directory listing?

Reference:

CodePudding user response:

Your questions are not related with the dockerfile, but with the apache configuration instead.

Apache configuration file httpd.conf might be usually found in /etc/httpd or in /etc/apache/sites-available or in similar paths, check the documentation of your Apache version.

Then,


to change your default index file to be index.html, you need to configure

DirectoryIndex index.html 

to get a directory listing when no index file is found; you use, inside a <Directory>tag,

Options  Indexes

and, finally, for apache serving files in a case-insensitive way, you need to hack the system some way. Linux is case-sensitive file system. So,


you either change all your file names to be lowercase and the rewrite all urls to be lowercase

    RewriteEngine On    
    RewriteCond %{REQUEST_URI} [A-Z]
    RewriteRule ^(.*)$ ${tolower:$1} 

or mount your directory into a case-insentive samba filesystem.

Supose you are serving opt/www you make a SMB share for localhost only, then mount the Samba share to /shared/www and configure apache to use it.

  • Related