Tools · 3 min read · Updated

How to Remove /blog/ from URLs Using Cloudflare Free Plan

Removing blog from URLs with Cloudflare

If your website uses URLs like:

  • https://webocreation.com/blog/opencart-guide
  • https://webocreation.com/blog/seo-tips
  • https://webocreation.com/blog/category/news

And you want to remove /blog/ from the URLs without upgrading to a paid Cloudflare plan, you can accomplish this using Cloudflare Redirect Rules.

For example:

  • https://webocreation.com/blog/opencart-guide → https://webocreation.com/opencart-guide
  • https://webocreation.com/blog/seo-tips → https://webocreation.com/seo-tips

The challenge is making sure that /blog and /blog/ themselves are not redirected to the homepage.

In this tutorial, we’ll configure a Cloudflare Redirect Rule that handles this correctly using features available on the Free plan.

Step 1: Open Cloudflare Redirect Rules

  1. Log in to your Cloudflare Dashboard.
  2. Select your website.
  3. Navigate to Rules → Redirect Rules.
  4. Click Create rule.
  5. Give your rule a name, such as Remove /blog/ from URLs.

Step 2: Configure the matching condition

Under When incoming requests match, select Custom filter expression.

Use this expression:

(http.request.uri.path wildcard "/blog/*")
and (http.request.uri.path ne "/blog/")

This condition matches URLs beginning with /blog/ while excluding the exact /blog/ URL.

Step 3: Configure the URL redirect

Under Then → URL redirect, select Dynamic.

Enter the following expression:

wildcard_replace(
  http.request.uri.path,
  "/blog/*",
  "/${1}"
)

Set the redirect status code to 302 while testing.

Enable Preserve query string if you want to retain URL parameters.

Once you have verified that everything works, change the status code to 301 (Permanent Redirect).

Step 4: Save and deploy the rule

Click Deploy to activate your Redirect Rule.

Your Cloudflare Free plan can handle this using wildcard matching without requiring regex replacement or paid WAF features.

Expected results

After deploying the rule, your URLs should behave as follows:

Original URLExpected behavior
/blogNo redirect
/blog/No redirect
/blog/opencart-guide/opencart-guide
/blog/seo-tips/seo-tips
/blog/category/news/category/news
/blog/category/tutorials/category/tutorials

Why do we exclude /blog/?

Wildcard matching can match an empty value for *. Consequently, a wildcard pattern such as /blog/* can also match /blog/.

This can cause unwanted redirects to your homepage.

That’s why we explicitly exclude /blog/ using:

(http.request.uri.path ne "/blog/")

The /blog URL does not match the /blog/* pattern because it does not contain the trailing slash.

Important SEO considerations

When removing a URL prefix, remember these SEO considerations:

  1. Use 301 redirects: Once testing is complete, use permanent redirects to tell search engines that your content has moved.
  2. Update internal links: Update your website’s internal links to point directly to the new URLs.
  3. Update canonical URLs: Make sure your canonical tags reference the new URLs without /blog/.
  4. Update your sitemap: Submit the updated sitemap containing the new URLs to Google Search Console.
  5. Check for redirect loops: Ensure that the new URLs serve content directly and do not redirect back to the old URLs.

Conclusion

You don’t need a Cloudflare Business plan or paid WAF features to remove /blog/ from your website URLs.

Using Cloudflare Free Redirect Rules with wildcard_replace() allows you to remove the /blog/ prefix while keeping /blog and /blog/ accessible without redirecting them to your homepage.

This is a simple solution for website owners who want cleaner URLs without upgrading their Cloudflare subscription.

Filed underTools
Rupak Nepali
Written byRupak Nepali

Rupak Nepali is a web developer, manage Webocreation website and the author of six books:
Getting Started with OpenCart Module Development (Packt, 2013),
OpenCart Theme and Module Development (Packt, 2015),
OpenCart 4: Dev Guide for Themes & Extensions (2024),
OpenCart 4: User Manual (2025),
Cloudflare for the Enterprise Website (2026) and
The Technical Web Guide for Marketers (2026).
Rupak has built OpenCart stores and extensions since 2010, has published more than 600 tutorials on Webocreation, and shares free OpenCart extensions on GitHub.
Find Rupak on
GitHub | Amazon | LinkedIn | X | YouTube.

Leave a Reply

Your email address will not be published. Required fields are marked *