Reputation: 8123
I'm building a site with Snap.
In my routes, how do I match on the site's root directory?
i.e.
routes = [(ByteString, Handler App App ())]
routes = [("/", redirect "www.google.com")]
The above code doesn't redirect when called at(localhost:8000/).
Upvotes: 0
Views: 158
Reputation: 18503
If you have a template called index.tpl
, then the "/"
handler will never get called. I found this out through trial and error.
Upvotes: 2
Reputation: 2727
You need to add "http://" to the URI. This works in my machine:
routes = [("/", redirect "http://www.google.com")]
You can also use ifTop
:
site :: Snap ()
site = ifTop (redirect "http://www.google.com) <|>
route routes
Where routes
contains the remaining routes of your site.
Upvotes: 1