Mobile app version of vmapp.org
Login or Join
Kristi941

: 301 or 302 redirect for mobile/non-mobile pages I'm setting up redirection for mobile/non-mobile pages. User agent is detected and redirected appropriately, but the ?mobile=1 or ?mobile=0 flag

@Kristi941

Posted in: #301Redirect #302Redirect #Mobile #Redirects #Seo

I'm setting up redirection for mobile/non-mobile pages. User agent is detected and redirected appropriately, but the ?mobile=1 or ?mobile=0 flag can be used to force a switch. When that flag is used, I always do a 301 redirect because the ?mobile= links should not be indexed, just their targets. Is this a correct assumption?

Additionally, there is the case of redirection by trying to visit the mobile link /m with a non-mobile user agent and vice versa. In this case I want to do a 301 redirect as well (mostly because it makes the code simpler), but I think it also makes sense to me semantically; the target URL for your user agent is the correct one.

A coworker is insisting that /m visits by a non-mobile user agent should do a 302 redirect because the /m link is valid. However, the only way to make it valid is to either visit ?mobile=1 at the same time (which would already do a 301 redirect to /m) or to have something else on our website that sets the session to mobile, which is something we either rarely or never do.

Google's documentation seems to indicate that it actually doesn't matter if you use 302 or 301 for mobile/non-mobile redirection (at least if you have the Vary: User-Agent header and/or rel="alternate" link specification; we currently have neither, though).

My arguments for the 301 are:


Simplifies the code a bit
Non-mobile spiders will not index the /m link, so theoretically it should not show up for search results which spares non-mobile users an additional redirect when they visit the link (similar situation for mobile spiders/users)


However, he does have a point about both of the URLs being valid. Which status code would be better to use in this case?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kristi941

1 Comments

Sorted by latest first Latest Oldest Best

 

@Samaraweera270

It sounds like you've answered your own question. As per Google's documentation, the redirection method doesn't matter, though I must say I too would lean towards using 302 – as your colleague says, both URLs are valid and using 302 is common in other conditional redirect scenarios.

However doing either without using Google's recommended Vary and rel="alternate" (desktop referencing mobile) and rel="canonical" (mobile referencing desktop) seems prone to problems. I'd strongly recommend implementing these.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme