简体   繁体   中英

Serve static HTML files in Apache

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:

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 rewrite all urls to be lowercase

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

or mount your directory into a case-insensitive 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 reconfigure apache to use the new mounted samba share. All files in opt/www will be mirrored as case-insentitive in shared/www

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM