Apache, Nginx & Caddy Configuration Recipes
Standalone Qwiki uses clean URLs (/category/slug and /category/subcategory/slug) and stores manifests (qwiki.json, users.json) and documents (content/, data/) inside the application root. Configure your web server to route unknown paths to index.php and deny direct HTTP access to raw data stores.
Apache (.htaccess Included)
Standalone Qwiki ships with a production .htaccess that:
- Enforces HTTPS redirects (when
mod_rewriteis activeβcomment out lines 7β8 if terminating TLS at an upstream load balancer without forwarding HTTPS state). - Blocks direct HTTP access to
content/(RewriteRule (^|/)content(/|$) - [F,L]). - Returns
404for missing static assets instead of falling through toindex.php. - Routes clean URLs to
index.php?path=$1. - Denies direct downloads of
*.json,*.md, and*.markdownfiles across both Apache 2.4 (Require all denied) and Apache 2.2 (Order allow,deny).
Ensure AllowOverride All is enabled in your Apache <Directory> block so .htaccess rules take effect.
Nginx
server {
listen 80;
server_name wiki.example.com;
root /var/www/standalone-qwiki;
index index.php index.html;
# Block sensitive data directories and raw files
location ~* ^/(?:content|data)/ {
deny all;
return 403;
}
location ~* \.(?:json|jsonl|md|markdown|bak)$ {
deny all;
return 403;
}
# Clean URL front-controller routing
location / {
try_files $uri $uri/ /index.php?path=$uri&$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}
Caddy
wiki.example.com {
root * /var/www/standalone-qwiki
encode gzip
@blocked {
path /content/* /data/* *.json *.jsonl *.md *.markdown *.bak
}
respond @blocked 403
php_fastcgi unix//run/php/php8.3-fpm.sock {
try_files {path} {path}/ /index.php?path={path}&{query}
}
file_server
}
Unlike Apache, Nginx and Caddy do not read .htaccess files. Always include the explicit /content/, /data/, and *.json/*.jsonl/*.md deny rules shown above when deploying on Nginx or Caddy.