--- title: "静态站点托管" type: concept tags: [] --- ## Definition 静态站点托管(Static Site Hosting)指将静态 HTML、CSS、JavaScript 文件部署到 Web 服务器上对外提供服务。Quartz 支持 Nginx、Apache、Caddy 三种自托管方案。 ## Hosting Solutions - [[Nginx]] — 高性能反向代理和静态文件服务 - [[Apache]] — 通过 .htaccess 进行 URL 重写配置 - [[Caddy]] — 自动 HTTPS,Caddyfile 简明配置 ## Configuration ### Nginx 需要配置 try_files 规则处理无扩展名 URL: ```nginx try_files $uri $uri.html $uri/ =404; ``` ### Apache 需要启用 mod_rewrite 模块处理 .html 扩展名: ```apache RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI}.html -f RewriteRule ^(.*)$ $1.html [L] ``` ### Caddy Caddyfile 配置: ```caddy example.com { root * /path/to/quartz/public try_files {path} {path}.html {path}/ =404 file_server } ``` ## Related Concepts - [[静态站点生成]] - [[HTTPS]] - [[域名]] - [[Let's Encrypt]]