How to externally host a mobile website?
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.comor at leastm.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.comwould redirect tom.mysite.com m.mysite.comwould point tomysite.com/mobile/?app=1would 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?
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.
Comments
Post a Comment