Get the latest updates, in-depth tutorials, and exclusive resources on themes, templates, and code. Stay ahead with our expert insights—join our Telegram channel today!

How to Permanently Remove ?m=1 from URLs in Blogger

Learn how to prevent ?m=1 redirection in Blogger using Cloudflare Workers or Rewrite Rules to improve indexing and SEO.

If you own a Blogger blog, you might have noticed that when accessed on a mobile device, your blog’s URL gets appended with the query parameter ?m=1. While Blogger claims that this redirection is harmless, it can lead to issues in Google Search Console such as:

Remove ?m=1 from Blogger URLs
Learn how to stop ?m=1 redirection in Blogger for better SEO.
  • Alternative page with proper canonical tag
  • Page with redirect

These errors may affect your blog’s indexing and performance in search engines.

Why Does This Happen?

When Google’s smartphone crawler visits a post like /2025/01/post.html (found in your sitemap.xml), it gets redirected to /2025/01/post.html?m=1 because the crawler mimics a mobile device. Since the canonical tag points to /2025/01/post.html, the ?m=1 version is marked as an alternate page with proper canonical tag. This can lead to indexing delays and potential SEO issues.

Workarounds to Prevent ?m=1 Redirection

Blogger does not offer a native way to stop this behavior, but there are two server-side workarounds using Cloudflare:

1. Using Cloudflare Workers (Recommended)

This method prevents redirection by modifying responses at the server level. It works as a middleware between the user and Blogger, ensuring mobile and tablet users do not get redirected to ?m=1.

Steps to Implement:

  1. Login to Cloudflare and go to the Workers & Pages section.
  2. Click on Create application > Workers > Create Worker.
  3. Rename the worker as m-redirect-blogger and Deploy it.
  4. Click Edit Code and replace it with the following:
/**
 * Environment interface
 * 
 * @typedef Env
 * @property {string} my_var
 */

// Constants
const MOBILE_REGEX = /(?:phone|windows\s+phone|ipod|blackberry|(?:android|bb\d+|meego|silk|googlebot) .+? mobile|palm|windows\s+ce|opera\ mini|avantgo|mobilesafari|docomo|KAIOS)/i;
const TABLET_REGEX = /(?:ipad|playbook|(?:android|bb\d+|meego|silk)(?! .+? mobile))/i;

/**
 * Detects the device type from the User-Agent.
 * 
 * @param {string | null} userAgent
 * @returns {"mobile" | "tablet" | "desktop"}
 */
const getDeviceType = (userAgent) => 
  MOBILE_REGEX.test(userAgent || "") ? "mobile" :
  TABLET_REGEX.test(userAgent || "") ? "tablet" :
  "desktop";

/**
 * An object with workers handlers
 * 
 * @type {ExportedHandler<Env>}
 */
const worker = {
  async fetch(request, env, context) {
    const deviceType = getDeviceType(request.headers.get("User-Agent"));

    // No modifications needed for desktop users
    if (deviceType === "desktop") return fetch(request);

    const proxiedUrl = new URL(request.url);
    proxiedUrl.searchParams.set("m", "1");

    // Create a new request only when necessary
    const proxiedRequest = new Request(proxiedUrl, {
      method: request.method,
      body: request.body, // Use body directly without cloning unless needed
      headers: new Headers(request.headers), 
      redirect: "follow"
    });

    // Remove `Content-Length` if modifying request
    proxiedRequest.headers.delete("Content-Length");

    // Fetch the proxied request
    const proxiedResponse = await fetch(proxiedRequest);

    // Return response directly unless headers need modification
    return new Response(proxiedResponse.body, proxiedResponse);
  }
};

// Export handlers
export default worker;
  1. Click Save and Deploy.
  2. Go to Websites > Select your domain > Workers Routes > Add Route.
  3. Input your blog URL pattern like www.yourblog.com/* and assign it to m-redirect-blogger.

2. Using Cloudflare Rewrite Rules (Alternative)

If you don’t want to use Workers, you can apply a Rewrite Rule to modify URLs based on the User-Agent.

Steps to Implement:

  1. Go to Websites in Cloudflare Dashboard and select your domain.
  2. Navigate to Rules > Overview > URL Rewrite Rules.
  3. Click Create Rule and name it Rewrite Blogger Mobile URLs.
  4. Under Custom Filter Expression, paste:
http.request.full_uri wildcard "http*://www.itisuniqueofficial.com/*" and
(http.user_agent contains "mobi" or http.user_agent contains "Mobi")
  1. Under Query, select Rewrite to… > Dynamic, and enter:
wildcard_replace(http.request.uri.query, "*", "${1}&m=1")
  1. Click Deploy.

Limitations

  • Cloudflare Workers have usage limits on free plans.
  • Blogger does not officially support Cloudflare integration, so use these methods at your own risk.
  • Does not work on .blogspot.com subdomains as they do not allow Cloudflare DNS management.

Conclusion

While these methods do not completely eliminate Search Console warnings, they significantly reduce unnecessary redirections and optimize indexing. If your blog is on a custom domain with Cloudflare, using Cloudflare Workers is the most effective way to prevent ?m=1 redirection. However, always proceed with caution and test your changes to ensure your site remains accessible.


Have you implemented any of these solutions? Share your experience in the comments!

My name is It Is Unique Official, and I write news articles on current threats and trending topics. I am based in Parbhani, Maharashtra, India.

Post a Comment

Please avoid spamming in the comment section; all comments are moderated by the admin for quality and relevance.