4

I've built a cool mobile website/app using JQuery Mobile. I want to offer that to clients, but I want to use my own hosting.

Here's what I want to do

If a user uses a mobile device to visit client.com, I want them to see the contents of mysite.com/mobile/?app=1.

If a mobile user visits client.com/something, I want them to see mysite.com/mobile/detail.php?i=something&app=1.

Requirements

  • The browser should still show the url on client.com or at least m.client.com.
  • The redirect should not break Jquery Mobile (therefore iFrames are out of the question)
  • The redirect should be easy to set-up for my client. Ideally a copy and paste of some javascript code.

Here's what I've come up with

I've thought of something, but I'm not sure if it's going to work and IF it's going to work, whether it's a good solution.

  • A small javascript would detect a mobile device and redirect to m.client.com.
  • Cname m.client.com would redirect to m.mysite.com
  • m.mysite.com would point to mysite.com/mobile/
  • ?app=1 would be appended by PHP.

I'm not even sure if that's going to work, and it requires too much effort for my clients.

I am willing to use almost any combination of techniques to achieve this. Javascript, Jquery, DNS zoning, HTAccess or anything else that would be good for it.

What would be the best way to do such a thing?

3
  • Fair enough. That would just require a simple mod rewrite. But I didn't yet do that, because I didn't think it would impact the solution. But you think it would make it easier? EDIT > A comment was here. It's gone now. Now it looks like I'm talking to myself.
    – Vic V
    Commented Jan 22, 2013 at 13:03
  • backbone.js and a RESTful API for content. Handle device detection on the server side, that way it goes fast before any output is sent to the browser. This is a good PHP mobile detection script: github.com/serbanghita/Mobile-Detect
    – Kenzo
    Commented Jan 22, 2013 at 19:46
  • I've checked it out, but backbone.js seemed slightly to complicated for my needs. Thanks anyway!
    – Vic V
    Commented Jan 27, 2013 at 13:23

1 Answer 1

0

I ended up doing it like this.

I ask my clients to create a file called mobile.php on their server. I provide them with about 7 lines of code, that CURLS the appropriate page from my server. The file also sends along context information, so mobile.php now functions as the complete mobile website. I then provide a javascript browser detection script. I do this with javascript, because this will be compatible with all other sites.

It may not be the most efficient way, but it did the job, while still honoring the requirements I wrote in the first post.

2
  • What happens for users with JavaScript off, or search engines? You can, and should, handle mobile detection on the server side.
    – Kenzo
    Commented Jan 27, 2013 at 20:32
  • You're right. I guess I'll offer the php redirect and only use javascript as a fallback only if a client really doesn't have the proper access to the host. Thanks!
    – Vic V
    Commented Jan 28, 2013 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.