Blogger url remove ?m=1 parameter using JavaScript or Cloudflare method

Remove ?m=1 from Blogger URLs to boost SEO & indexing. Use JavaScript for subdomains or Cloudflare methods for custom domains.
Remove ?m=1 parameter from Blogger URLs

If you run a Blogger site, you’ve probably seen the unwanted ?m=1 parameter at the end of your mobile URLs. At first glance, it looks like a harmless string of characters. But in reality, this tiny addition can cause big problems for your blog’s performance, SEO ranking, and overall indexing.

Google Search Console often reports errors like “Page with redirect” or “Alternative page with proper canonical tag” because of ?m=1. These errors confuse search engines, create duplicate versions of the same page, and prevent your posts from reaching their true potential in search results. Over time, it can slow down organic traffic and hurt your blog’s visibility.

The good news is that this issue is completely fixable. Whether you’re using a free Blogger subdomain or a custom domain connected with Cloudflare, there are proven solutions to remove ?m=1 parameter. From quick JavaScript fixes to powerful server-side methods, you can clean up your URLs, strengthen your SEO, and keep your blog looking professional.

Table of Contents
Info! Below, three methods are given. You can use any one of them, but if you have a Blogger subdomain, you should use only the first method. The others are not for you — they are meant for those who have a custom domain.

Method 1: Using JavaScript Code

If you are using a free Blogger subdomain like yourblog.blogspot.com or custom domain, the easiest way to remove ?m=1 from URLs is a simple JavaScript fix. This method works entirely on the client side, requires no Cloudflare or server setup, and cleans the URL as soon as the page loads.

This JavaScript code removes ?m=1 to show a clean URL, improves SEO, makes it user-friendly, and avoids duplicate entries in browser history. This is the easiest way to hide ?m=1, but it does not completely fix the SEO issue.

If you want to use it, follow these steps:

  1. Go to Blogger Dashboard → Theme → Edit HTML.
  2. Add the following script inside the <head> tag:
    <script>
    if(window.location.search.indexOf('?m=1') !== -1){
      var cleanUrl = window.location.href.replace('?m=1','');
      window.history.replaceState(null, null, cleanUrl);
    }
    </script>
    
  3. Save changes and test your blog on a mobile device. The URL will now display without ?m=1.

How to remove javascript code

If you ever need to remove JavaScript code, go to Blogger Dashboard → Theme → Edit HTML. Then, find the place where you pasted JavaScript code, remove this code, and click Save button. Your code will be removed.

Let me explain again: these two methods are only for those who have a custom domain. Your domain must be connected to Cloudflare. If your domain is not on Cloudflare, you cannot apply these methods until you move your domain to Cloudflare.

If you don’t know how to connect your domain to Cloudflare, simply search on YouTube connect domain to Cloudflare, connect your domain to Cloudflare, and then you can use these two methods.


Method 2: Remove ?m=1 Using Cloudflare Rewrite Rule

The easiest way to remove ?m=1 from a Blogger site is by using Cloudflare Rewrite Rules. This server-side method ensures mobile visitors access clean URLs, preventing SEO issues like canonical or redirect errors.

Benefits:

  • Works before the page reaches the browser.
  • Reduces “Alternative page with proper canonical tag” and “Page with redirect” errors in Search Console.
  • Provides better control over mobile URL handling.

Follow the steps below to configure Cloudflare URL Rewrite Rules for your blog. This will automatically clean mobile URLs, hiding the unnecessary ?m=1 parameter while keeping your site fully functional.

  1. Make sure your DNS is managed by Cloudflare and the proxy is enabled.
  2. Go to Cloudflare Dashboard → select your domain → Click Rulesclick Overview
  3. Click "Create rule"
  4. Select "URL Rewrite Rules"
  5. Name the rule – For example: Rewrite Blogger Mobile
  6. Under "If incoming requests match…”, select Custom filter expression
    Don't add "Field, Operator, Value".
    Click "Edit Expression".
    Replace your blog URL and paste the following code:
    http.request.full_uri wildcard "http*://www.edusynth.in/*" and
    (http.user_agent contains "mobi" or http.user_agent contains "Mobi")
  7. Path: select Preserve
  8. Query: select Rewrite to…
  9. Select Dynamic
  10. Paste this code on the side of Dynamic:
    wildcard_replace(http.request.uri.query, "*", "${1}&m=1")
  11. Click "Deploy" button.

Now, when mobile visitors access your blog, they will see clean URLs without the unnecessary ?m=1 parameter.

How to remove Cloudflare Rewrite Rule

If you ever need to remove Cloudflare Rewrite Rule and want to delete your existing rule, follow these steps.

  1. Go to Cloudflare Dashboard
  2. Click your domain
  3. On the left side → Go to Rules
  4. Click Overview
  5. View your rule name
  6. On the right side, you will see Active. Three dots are in front of it. Click on those three dots
  7. Click the Delete button, then click the Delete button again. Your rule will be deleted.
If you have already created a Cloudflare Rewrite Rule, do not use the third method as it may cause errors. Between Method 2 and Method 3, use only one.

Method 3: Remove ?m=1 Using Cloudflare Workers

You can completely control the ?m=1 redirection using Cloudflare Workers. This method works server-side, accurately detects mobile, tablet, and desktop devices, and ensures visitors see clean URLs.

Benefits of Cloudflare Workers:

  • Works server-side, so no unnecessary redirection reaches the browser.
  • Detects mobile, tablet, and desktop devices accurately.
  • Reduces SEO errors like “Alternative page with proper canonical tag”.
  • Fully customizable – you can even modify headers or HTML if needed.

Setup: Follow the setup below to configure Cloudflare Workers for your blog. This ensures mobile and tablet users get the correct page without unnecessary ?m=1 redirects.

Step 1: Open Workers Section

  1. Go to Cloudflare Dashboard
  2. In the left sidebar, Compute (Workers) click Workers & Pages.
  3. Click the Workers tab at the top.
  4. Create a Worker, Click Start with Hello World!
  5. Give it a name, e.g., prevent-redirect-new
  6. Click Deploy (don’t worry about the default Hello World! code).

Step 2: Edit Worker Code

  1. After deployment, click Edit Code (right side top).
  2. Remove the existing code.
  3. Paste the following code:
    
    /**
     * 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;
    
    /**
     * A helper function to get the device type from user-agent
     * 
     * @param {string | null} userAgent
     * 
     * @returns {"mobile" | "tablet" | "desktop"}
     */
    const getDeviceType = (userAgent) => {
      if (typeof userAgent === "string") {
        if (MOBILE_REGEX.test(userAgent)) {
          return "mobile";
        }
    
        if (TABLET_REGEX.test(userAgent)) {
          return "tablet";
        }
      }
    
      // Everything else not matched above will be considered as desktop
      return "desktop";
    }
    
    /**
     * An object with workers handlers
     * 
     * @type {ExportedHandler<Env>}
     */
    const worker = {
      async fetch(request, env, context) {
        // Get the device type from user-agent header
        const deviceType = getDeviceType(request.headers.get("User-Agent"));
    
        const proxiedUrl = new URL(request.url);
        // Set the search param 'm' with value '1' if the device type is not 'desktop'
        if (deviceType !== "desktop") {
          proxiedUrl.searchParams.set("m", "1")
        }
    
        const proxiedRequest = new Request(proxiedUrl, {
          method: request.method,
          body: request.body,
          headers: request.headers,
          redirect: "follow"
        });
    
        const proxiedResponse = await fetch(proxiedRequest);
    
        const response = new Response(proxiedResponse.body, proxiedResponse);
    
        // OPTIONAL: You can further modify the response here :)
    
        return response;
      }
    }
    
    // Export handlers
    export default worker;
    
  4. Click Save and Deploy.

This code ensures mobile and tablet users get the correct page without unnecessary redirection.

Step 3: Set Worker Routes

  1. Go to Cloudflare Dashboard → click your domain
  2. Go to sidebar, click Workers Routes
  3. Click Add Route
  4. Enter the following:
    Route URL:
    www.yourblog.com/*
    (replace with your domain)
    Don't remove it'*'
  5. Select Worker: prevent-redirect-new
  6. Click "Request limit failure mode" select Fail open (proceed)
  7. Click Save

This tells Cloudflare which pages should use the Worker. All pages under your domain will now be handled automatically.

Step 4: Test Your Blog

  1. Open your blog on a mobile device.
  2. Check the URL – it should not show ?m=1.
  3. Open the blog on desktop – everything works normally.

How to remove Cloudflare Workers rule

If you ever need to remove a "Cloudflare Workers rule" or if you face any error in the future and want to delete this Workers rule, follow these steps.

Remove Workers Routes

  1. Go to Cloudflare Dashboard
  2. Click your domain
  3. On the left side → click Workers Routes
  4. View your Workers Routes
  5. On the right side, Click edit button
  6. Click remove button and click again remove button

Remove Workers Routes

  1. Go to Cloudflare Dashboard
  2. View Compute (Workers) → Click Workers and pages
  3. There you will see the name you created. Click on that name.
  4. A new screen will appear with these tabs: Metrics | Deployments | Bindings | Logs | Settings. Click on the Settings tab.
  5. Scroll down to the bottom, and on the right side you will see the Delete button. Click on Delete button.
  6. You will see a message like this: Deleting "your-rule-f544" is permanent and cannot be....
    You need to copy the part "your-rule-f544" and paste it below.
  7. Click the Delete button, and finally your Workers page will be deleted.

Remove ?m=1 parameter FAQ

How do I remove ?m=1 from Blogger URLs?

You can remove ?m=1 from Blogger URLs either using a simple JavaScript code inside the <head> tag, or by applying Cloudflare Rewrite Rules / Workers for custom domains. JavaScript cleans the URL on the client side, while Cloudflare provides a server-side fix for SEO.

Is ?m=1 in Blogger bad for SEO?

Yes, ?m=1 can create duplicate URL issues and cause errors like “Alternative page with proper canonical tag” in Google Search Console. Fixing it ensures clean URLs, reduces redirects, and improves indexing.

Can I remove ?m=1 without Cloudflare?

Yes, if you are using a free Blogspot subdomain, you can add a JavaScript snippet to automatically remove ?m=1 when the page loads. However, this method only works on the browser side and does not fully solve SEO issues.

What is the best way to fix ?m=1 redirection in Blogger?

The most reliable solution is using Cloudflare Rewrite Rules or Workers for custom domains. These work server-side, prevent unnecessary redirects, and ensure Google indexes the correct URL for both mobile and desktop.

Related Posts

Final Thought

Fixing the ?m=1 issue is important for both SEO and indexing. If you are on a Blogger subdomain, the JavaScript method is the simplest choice. For those using a custom domain connected to Cloudflare, Rewrite Rules or Workers provide a more permanent and SEO-friendly solution. Choose the method that suits your setup and keep your blog clean and professional.

Post a Comment