A modern HTTP web server index for Apache httpd, lighttpd, nginx, and other PHP-capable servers.
Replaces the default directory listing with a feature-rich interface: icons, thumbnails, previews, search, sorting, filtering, and more.
This is a fork of lrsjng's h5ai, which is no longer maintained.
| Feature | Details |
|---|---|
| Directory Listing | Three view modes: details, grid, and icons. Configurable icon sizes (10–300px). |
| Thumbnails | Auto-generated for images, video (FFmpeg), PDF/PS (ImageMagick), and archives (Zip/Rar). WebP output with EXIF rotation support. |
| Custom Thumbnails | Place a _thumb folder inside any directory to use custom folder icons. |
| Preview | Image, audio (HTML5), video (HTML5), text with syntax highlighting (highlight.js), and Markdown rendering (marked). |
| Search | Server-side recursive search with advanced pattern matching. |
| Filter | Client-side real-time filtering of the current directory. |
| Tree Sidebar | Collapsible folder tree in a sidebar. |
| Download | Packaged download of selected files or entire folders (tar/zip). |
| Custom Headers/Footers | Drop _h5ai.header.html or _h5ai.footer.html (or .md) into any directory. |
| Themes | Icon themes via folders in images/themes/. Ships with "comity" and "default". |
| Localization | 35 languages. Auto-detects browser language. |
| Fallback Mode | Simple HTML table for text browsers and no-JavaScript environments. |
| Auto-refresh | Live directory updates at a configurable interval. |
| History API | Fast browsing without full page reloads. |
| Info Page | Admin page at /_h5ai/ showing server info, PHP config, and extension status. |
- PHP 7.0.0+ (tested with PHP 8.4.0)
- A web server: Apache httpd, nginx, lighttpd, or Cherokee
- PHP GD extension (for image thumbnails)
| Dependency | Purpose |
|---|---|
| FFmpeg / FFprobe | Video thumbnails |
| GraphicsMagick / ImageMagick | PDF/PS thumbnails |
| PHP FileInfo | MIME type detection |
| PHP SQLite3 | Thumbnail cache database |
| PHP Zip | Zip thumbnail extraction, zip downloads |
| PHP RAR | RAR thumbnail extraction |
du |
Folder size calculation |
tar / zip |
Archive downloads |
git clone https://github.com/flowerey/h5ai.git
cd h5ai
npm install
npm run buildThe build produces a ready-to-deploy _h5ai/ folder in build/.
- Copy the entire
_h5ai/folder frombuild/to your document root. - Make the cache directories writable by the web server:
chown -R www-data:www-data _h5ai/public/cache _h5ai/private/cache
- Configure your web server (see Server Configuration).
- Access the info page at
http://yourserver/_h5ai/to verify the setup.
Important: Do not install files from src/ directly — they must be preprocessed via the build.
_h5ai/
public/ ← Web-accessible
index.php ← Entry point
cache/ ← Thumbnail cache (writable)
css/styles.css ← Compiled CSS
ext/ ← Custom user scripts/styles
images/ ← Icons, themes, fallback images
js/scripts.js ← Bundled JavaScript
private/ ← NOT web-accessible
cache/ ← Server-side cache
conf/ ← Configuration (options.json, types.json, l10n/)
php/ ← PHP application code
Place this in your site's <VirtualHost> or .htaccess at the document root:
DirectoryIndex index.html index.php
RewriteEngine On
# Route all directory requests through h5ai
RewriteRule ^/$ /_h5ai/public/index.php [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI}/index\.(html|php)$
RewriteRule ^(.+)$ /_h5ai/public/index.php [L,QSA]Ensure these modules are enabled: mod_rewrite, mod_headers, mod_expires, mod_deflate.
server {
listen 80;
server_name example.com;
root /var/www/html;
index index.html index.php;
location / {
try_files $uri $uri/ /_h5ai/public/index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}server.modules += ("mod_rewrite")
url.rewrite-if-not-file = (
"^/(.*)/$" => "/_h5ai/public/index.php/$1"
)All options live in _h5ai/private/conf/options.json. Key sections:
| Section | Key Options |
|---|---|
| View | binaryPrefix, disableSidebar, fallbackMode, fastBrowsing, hidden[], maxIconSize, modes, theme, sizes[] |
| Thumbnails | enabled, img[], mov[], doc[], ar[], delay, size (240px), seek (50%), exif |
| Preview | Image, audio, video, text (syntax modes: 0=float, 1=fixed, 2=markdown, 3=highlight) |
| Search | enabled, advanced, debounceTime, ignorecase |
| Download | enabled, type (php-tar/shell-tar/shell-zip), packageName |
| Sort | column (0=name, 1=date, 2=size), natural, folders (top/in-place/bottom) |
| Tree | enabled, maxSubfolders (50), naturalSort |
| Custom | enabled, stopSearchingAtRoot (custom header/footer propagation) |
| L10n | enabled, lang, useBrowserLang |
| Info | enabled, qrcode, QR code colors |
| Autorefresh | enabled, interval (5000ms) |
See options.json for the full list with documentation.
File type mappings are in types.json.
- Node.js ≥ 22.22.0 (or ≥ 24.15.0, or ≥ 26.0.0)
- npm ≥ 10.0.0
npm install # Install dependencies
npm run lint # Lint with ESLint
npm test # Run tests with Vitest
npm run build # Development build (with sourcemaps)
npm run build -- --release # Production build (minified, creates zip)The build script (scripts/build.mjs) processes:
- JavaScript — esbuild bundles
src/_h5ai/public/js/scripts.jsas an IIFE, withpre.js(browser feature detection) prepended as a banner. - CSS —
src/_h5ai/public/css/styles.lessis compiled via Less, then post-processed with Autoprefixer and cssnano. - Templates — Pug templates in
src/_h5ai/private/php/pages/are compiled to PHP. - Static assets — PHP classes, images, config files, and root markdown files are copied with
{{VERSION}}replaced. - Release zip —
build/h5ai-<version>.zipis created with all deployment files.
src/_h5ai/
private/
conf/ ← Configuration files (options.json, types.json, l10n/)
php/
class-bootstrap.php ← Entry point, autoloading, routing
core/ ← Core classes (API, context, session, setup, ...)
ext/ ← Extensions (archive, search, thumb, custom, cachedb)
pages/ ← Pug templates → PHP pages
public/
index.php ← Web entry point
css/ ← LESS source → compiled to styles.css
js/
lib/ ← Source JS modules
core/ ← Core (location, types, event, ...)
ext/ ← 18 extension modules
main/ ← Entry points (index.js, info.js)
model/ ← Data models (item.js)
util/ ← DOM, utilities
view/ ← View components (sidebar, notifications, ...)
pre.js ← Browser feature detection
images/
themes/ ← Icon themes (comity/, default/)
ui/ ← UI SVG icons
ext/ ← User custom scripts/styles
Tests run under Vitest with a jsdom environment:
npm testTest files live in test/tests/ and use ES module imports.
MIT License — Copyright (c) 2020 Lars Jung (https://larsjung.de)
See the full license text.
h5ai uses these projects (all MIT-licensed):
- highlight.js — Syntax highlighting
- marked — Markdown rendering
- qrcode — QR code generation
- normalize.css — CSS reset
- Material Design Icons — Some icons (CC BY 4.0)
- Original project: https://github.com/lrsjng/h5ai
- This fork: https://github.com/flowerey/h5ai
- Issues: https://github.com/flowerey/h5ai/issues
- Releases: https://github.com/flowerey/h5ai/releases
- Icon themes: https://github.com/lrsjng/h5ai-themes