mirror of
https://github.com/caddyserver/website.git
synced 2025-04-24 14:06:17 -04:00
docs: Cross-link root, file_server, php_fastcgi directives (#45)
* docs: Cross-link the `root` directive with file_server/php_fastcgi * Minor touch-ups Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
This commit is contained in:
parent
7f978fb437
commit
9791668f48
3 changed files with 33 additions and 8 deletions
|
@ -4,7 +4,9 @@ title: file_server (Caddyfile directive)
|
|||
|
||||
# file_server
|
||||
|
||||
A static file server. It works by appending the request's URI path to the [site's root path](/docs/caddyfile/directives/root).
|
||||
A static file server. It works by appending the request's URI path to the [site's root path](/docs/caddyfile/directives/root). By default, it enforces canonical URIs; if necessary, requests to directories will be redirected to have a trailing forward slash, and requests to files will be redirected to strip the trailing slash.
|
||||
|
||||
Most often, the `file_server` directive is paired with the [`root`](/docs/caddyfile/directives/root) directive to set file root for the whole site.
|
||||
|
||||
|
||||
## Syntax
|
||||
|
@ -19,7 +21,7 @@ file_server [<matcher>] [browse] {
|
|||
```
|
||||
|
||||
- **browse** enables file listings for requests to directories that do not have an index file.
|
||||
- **root** sets the path to the site root for just this file server instance, overriding any other. Default: `{http.vars.root}` or the current working directory. Note: When specified as a subdirective like this, only this directive will know this root; for other directives (like [try_files](/docs/caddyfile/directives/try_files) or [templates](/docs/caddyfile/directives/templates)) to know the same site root, use the [root](/docs/caddyfile/directives/root) directive, not subdirective.
|
||||
- **root** sets the path to the site root for just this file server instance, overriding any other. Default: `{http.vars.root}` or the current working directory. Note: This subdirective only changes the root for this directive. For other directives (like [`try_files`](/docs/caddyfile/directives/try_files) or [`templates`](/docs/caddyfile/directives/templates)) to know the same site root, use the [`root`](/docs/caddyfile/directives/root) directive, not this subdirective.
|
||||
- **hide** is a list of files to hide; if requested, the file server will pretend they do not exist. The active configuration file will be added by default.
|
||||
- **index** is a list of filenames to look for as index files. Default: `index.html index.txt`
|
||||
- **<template_file>** is an optional custom template file to use for directory listings.
|
||||
|
@ -44,3 +46,10 @@ Only serve static files out of the `/static` folder:
|
|||
```caddy-d
|
||||
file_server /static/*
|
||||
```
|
||||
|
||||
The `file_server` directive is usually paired with the [`root` directive](/docs/caddyfile/directives/root) to set the root path from which to serve files:
|
||||
|
||||
```caddy-d
|
||||
root * /home/user/public_html
|
||||
file_server
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue