Mobile app version of vmapp.org
Login or Join
RJPawlick198

: How to remove parameters from getting indexed on my desktop link from mobile site? I have example.com and m.example.com which both rel=canonical and rel=alternate to each other. On my mobile site

@RJPawlick198

Posted in: #Seo #Url #UrlParameters

I have example.com and m.example.com which both rel=canonical and rel=alternate to each other. On my mobile site I have a "desktop site" link that links to example.com?mobileOut that opts out of the mobile redirect. The issue is example.com/?mobileOut is getting indexed with the ?mobileOut param in the url. Can I nofollow the "desktop site" link and be safe?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @RJPawlick198

3 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

In your htaccess, you could add a condition to your rewrite to check if the referer is from your own site, then skip the mobile-user-agent check and proceed as normal. This way, someone lands on your page, gets redirected to m.example.com, clicks the Desktop link, your .htaccess file then, instead of redirecting back to m.example.com see's that the user was refered from your own site, thus skips the mobile check. This will also allow users to surf around your site without getting redirected back to m.example.com, but the next time they return, they'll be redirected to mobile as you'd expect. If you want the change to be kept for them accross sessions, you'd need to utilize a cookie.

An example re-write would be:

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone" [NC]
RewriteCond %{HTTP_REFERER} !^http://m.example.com/.* [NC]
RewriteRule (.*) m.example.com/ [R=302,L]


Which basically just says "if it's a mobile user-agent, and they were not referred here by my mobile site, then redirect them to my mobile site.

10% popularity Vote Up Vote Down


 

@Eichhorn148

There is a feature in Google Webmaster Tools that will solve this problem for Google. Navigate to:


Crawl
URL Parameters
Add Parameter


Put in "mobileOut" then "Doesn't affect the page content".

Save this change and Google will no longer crawl and index the mobileOut parameter. Instead it will favor the version of the URL without the parameter.

10% popularity Vote Up Vote Down


 

@Harper822

Your best bet here is to do a 301 redirection.

On your mobile site, you must have link code formatted like this:

<a href="example.com/?mobileOut">Desktop site</a>


First change all those to:

<a href="http://example.com">Desktop site</a>


Because when someone access just the domain name (without parameters), they should expect the website to load.

Once you done that, modify your sitemaps so that links that look like:

example.com/?mobileOut


get changed to:

example.com


Then finally, to make google finally understand things and to add additional safety, you need to make to create a redirection to the main site.

In an .htaccess file (create it if it doesn't exist) in the website document root folder, you can add the following:

RewriteEngine On
RewriteRule ^(?)?mobileOut$ example.com [R=301,L]


Or if what is handling the parameters is a PHP script, you could add the following to the top of it:

<?php
$qs=$_SERVER['QUERY_STRING'];
if ($qs=="mobileOut" || $qs=="?mobileOut"){
header("HTTP/1.1 301 Moved Permanently",true);
header("Location: example.com ,true);
}
.... rest of your PHP code here ....


Both pieces of code should cause anyone typing the site with the parameter to get redirected to the main site and when google recognizes this, they will refuse to index the page with the parameter, but instead index the domain name only.

I had to change the domain in my answer to example.com because this site doesn't like me to use mysite as the domain.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme