Closed mortenoc closed 8 years ago
@mortenoc charge
unfortunately can't do this splat-style of redirecting. the easiest way to do this is to simply put your views in a /en
directory. so instead of views/index.jade
, you'd edit it to views/en/index.jade
@kylemac actually we already have our files in /en and /ch folders. But I would like charge to redirect from / to /en by default. And if the user is from China, I will like to redirect to /ch.
@mortenoc if you need to geo-ip lookups, that is going to be outside the scope of charge. you'll want to use a more robust web-server, like nginx. nginx would also be able to do the splat-style redirects.
charge is meant to give you a configurable local web-server for local dev, but when you go to production (your live site) – you usually want to upgrade to something more traditional like apache or nginx.
we also really like to use netlify.com which can do the redirects and geo-lookup you're looking to do really easily, and it's tuned specifically for static sites.
@kylemac the geo-ip lookup is in place :) I was just confused about where to put the check. Thanks for clarifying the server setup! We are using roots, and we had mind to use roots in prod.
@mortenoc since roots' job is to compile to static files, you will still be using roots in prod 😉, we just don't suggest serving your files in watch
mode – and since your needs are beyond what charge
can satisfy you'll need to try a more powerful web-server.
good luck!
You should actually be able to run a splat redirect through pathologist, which is bundled with charge 🎉
charge({ routes: { '/': '/en' } })`
On the other hand if you are running a more complex redirect like /whatever
-> /en/whatever
, you'll probably want to switch over to nginx. Honestly if you are running any static site in production you probably want to use nginx, as @kylemac suggested.
@jescalan thanks! We will go for apache :)
We use roots which use charge as server. We would like to redirect all requests from http://localhost:1111/ to http://localhost:1111/en/. How is this done with roots?
Thanks!