Question

Subdomain for a mobile site?

Hi,

I have an ubuntu droplet running wordpress.

I developed a desktop and mobile theme for my Wordpress site and switch between the two using a wordpress plugin that detects the device the user is on and loads the appropriate theme accordingly. The only problem is this conflicts with varnish; since the URL is the same for both mobile and desktop browsers, sometimes desktop viewers will see the mobile site (and vice versa).

I’d like to setup a subdomain, m.mydomain.com, that gets loaded if the user is on a mobile device. But obviously I wouldn’t want to run two sites as this would cause headaches in managing the data.

What’s the best way to do this?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

What is the WordPress plugin that you are using to detect the device size? Does it support redirecting to a subdomain or are you looking for an entirely different solution?

There are also other ways that you can solve this problem. Using a more responsive theme that adapts to different form factors is becoming the standard solution. You could also look into something like Varnish Mobile Detect which will use a different backend based on the browser’s UserAgent.