A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.cloudflare.com/rules/snippets/examples/rewrite-site-links/ below:

Rewrite links on HTML pages · Cloudflare Rules docs

// Define the old hostname here.

const OLD_URL = "oldsite.com";

// Then add your new hostname that should replace the old one.

const NEW_URL = "newsite.com";

class AttributeRewriter {

constructor(attributeName) {

this.attributeName = attributeName;

const attribute = element.getAttribute(this.attributeName);

attribute.replace(OLD_URL, NEW_URL),

const rewriter = new HTMLRewriter()

.on("a", new AttributeRewriter("href"))

.on("img", new AttributeRewriter("src"));

const res = await fetch(request);

if (!res.headers.has("Content-Type")) {

const contentType = res.headers.get("Content-Type");

if (typeof contentType !== "string") {

// If the response is HTML, it can be transformed with

// HTMLRewriter -- otherwise, it should pass through

if (contentType.startsWith("text/html")) {

return rewriter.transform(res);


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4