Question

When a user lands on m.example-site.com/hello I would like to redirect them to hello.com/example.

How can I best accomplish this when using Moovweb? (Ideally it'd provide the fastest user experience.)

Was it helpful?

Solution 2

You can accomplish this using Javascript as well.

When the user lands on m.example-site.com/hello, add a <script> tag in the head of the document specifying a new window.location.

So, it'd look like:

<script>
// similar behavior as an HTTP redirect
window.location.replace("hello.com/example");
</script>

OTHER TIPS

If you're using the stdlib mixer, you can accomplish this by using the redirect_temporary or redirect_permanent functions in tritium.

The redirect_temporary(Text %url) function will cause a 302 HTTP redirect response to be returned to the client.

The redirect_permanent(Text %url) function will cause a 301 HTTP redirect response to be returned to the client.

To accomplish your specific example, you could match on the $path variable and then call whichever redirect function you'd prefer. Here's an example for a permanent redirect:

match($path, "/hello") {
  redirect_permanent("http://hello.com/example")
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top