How to re-direct mobile traffic to mydomain.com/m?


#1

Hi,

How to I redirect mobile traffic to mydomain.com/m instead of m.mydomain.com ?

Please post some insights into this.


#2

Possibly with Page Rules:

Otherwise you can do this within your webserver config, if you have access to it.


#3

@MarkMeyer

Thanks for taking the time to input your thoughts.

How do I make use of this option under SPEED settings to redirect mydomain.com mobile traffic to mydomain.com/m automatically.

If I am able to do it here , it will be very easy, have your tired this option before ?

I have no access to the hosting webserver.


#4

I’ve not tried this approach, but adding a Page Rule after setting the above Mobile Redirect may work:

  1. Set up that dummy subdomain of m.example.com: Create an A record that points to your IP address (no, it won’t actually use this A record because of the Page Rule below)
  2. Enable the Mobile Redirect feature
  3. As @MarkMeyer suggested, create a page rule that matches *m.example.com/* (the wildcards will match everything) that redirects to https://example.com/m (or https://example.com/m/$2 if your mobile paths match your desktop paths).

#5

@sdayman

Thanks for the input.

I think we are very close to the solution.

The redirection is now working correctly to the mydomain.com/m

Expect it is throwing error:

“redirected yoo too many times”

ERR_T00_MANY_REDIRECTS

any comments ?


#6

Shoot. Not close. I just realized that it redirects to a subdirectory in the non-mobile site, which makes that Mobile Redirect kick in again.

On another site, I had to manually redirect by adding this to the main page HTML head section:

<script type="text/javascript">
if (screen.width <= 800) {
document.location = "https://example.com/m";
}
</script>

#7

NO JOB TOO BIG :slight_smile:

Thank you, this is the simplest solution.

SOLVED


#8

This topic was automatically closed after 14 days. New replies are no longer allowed.