How do I create a redirect from mobile to desktop site?

329 views Asked by At

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

2

There are 2 answers

0
tdesikan On BEST ANSWER

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>
0
noj On

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")
}