Files
nexus/wiki/concepts/静态站点托管.md
2026-04-18 16:02:38 +08:00

55 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "静态站点托管"
type: concept
tags: []
---
## Definition
静态站点托管Static Site Hosting指将静态 HTML、CSS、JavaScript 文件部署到 Web 服务器上对外提供服务。Quartz 支持 Nginx、Apache、Caddy 三种自托管方案。
## Hosting Solutions
- [[Nginx]] — 高性能反向代理和静态文件服务
- [[Apache]] — 通过 .htaccess 进行 URL 重写配置
- [[Caddy]] — 自动 HTTPSCaddyfile 简明配置
## 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]]