Change the default phoenix page

In Phoenix the PageController seem to be the default controller with the function :index which renders the index.html.eex for the port http://0.0.0.0:4000/

Lets say i want instead to load SessionController :new function when i visit http://0.0.0.0:4000/. What is the best way to implement this?

I tried this approach in PageController but it seemed not to work

def index(conn, _params) do
    conn 
    |> redirect(to: session_path(conn, :new))
end

You can modify your router.ex to point / wherever You want.

1 Like

I must say that was too fast great. Back to your comment which part exactly do i modify in the file?

Maybe like this…

  scope "/", NextWeb do
    # Use the default browser stack
    pipe_through(:browser)

    get("/", SessionController, :new)
  end

Yeah this has worked for me well. Thanks @kokolegorille for your quick solution