diff --git a/caddy/readme.md b/caddy/readme.md index df33a9c..f3c3360 100644 --- a/caddy/readme.md +++ b/caddy/readme.md @@ -27,3 +27,18 @@ sudo systemctl reload caddy ``` Now visit `domain-name.com` again and it will be serving site over HTTPS. Caddy will automatically provision and renew TLS certificates from [LetsEncrypt](https://letsencrypt.org) + +## Redirects + +You might want to setup few redirects to your root domain for like IP Address and `www` sub domain. + +```Caddyfile +192.168.1.1, +www.domain-name.com { + redir https://domain-name.com{uri} +} +``` +You can setup this rule for multiple domains by either writing them space seperated or comma seperated as above. +`{uri}` specified at the end of domain name preserves the path from the URL user entered. +Now if anyone visits your website via server's IP address or using `www` subdomain they will be redirected to your root domain. +**It just looks cleaner.**