Nginx WWW Redirect ๐ยถ
Descriptionยถ
Automates the creation of Nginx server blocks that redirect all www.
subdomains to their non-www equivalents. Simple, idempotent, and SEO-friendly! ๐
Overviewยถ
This role will:
Discover existing
*.conf
vhosts in your Nginx servers directoryFilter domains with or without your
primary_domain
Generate redirect rules via the
web-opt-rdr-domains
roleOptionally include a wildcard redirect template (experimental) โญ๏ธ
Clean up leftover configs when running in cleanup mode ๐งน
All tasks are guarded by โrun onceโ facts and mode_cleanup
flags to avoid unintended re-runs or stale files.
Purposeยถ
Ensure that any request to www.example.com
automatically and permanently redirects to https://example.com
, improving user experience, SEO, and certificate management. ๐ฏ
Featuresยถ
Auto-Discovery: Scans your Nginx
servers
directory for.conf
files. ๐Dynamic Redirects: Builds
source: "www.domain"
โtarget: "domain"
mappings on the fly. ๐งWildcard Redirect: Includes a templated wildcard server block for
www.*
domains (toggleable). โจCleanup Mode: Removes the wildcard config file when
certbot_flavor
is set todedicated
andmode_cleanup
is enabled. ๐๏ธDebug Output: Optional
enable_debug
gives detailed variable dumps for troubleshooting. ๐