Question

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/).

Was it helpful?

Solution 2

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.

OTHER TIPS

If you have a template called index.tpl, then the "/" handler will never get called. I found this out through trial and error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top