phoebe
Forwarding all non-www to www
Hi, what’s the best way to forward all non-www (naked) traffic to the www subdomain whilst keeping url parameters intact? I am on gigalixir if that restricts (or simplifies anything) and my dns A record points to the ip provided by gigalixir, but I’d like to manage this within Elixir/Phoenix rather than at the dns level.
I am thinking along the lines of a plug, and some check on the subdomain part of conn.host but I don’t know where to actually apply the redirect outside of controllers.
Thanks for any help or light you can shed on this.
Most Liked
OvermindDL1
I’d imagine you could just redirect inside the plug then halt it to prevent further processing down the plug line?
thousandsofthem
I’d go with nginx here. If you really really want to keep your logic on elixir side, do as @OvermindDL1 said, create plug that checks out suff in @conn and does redirect + halt
phoebe
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









