Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

handle .php

Steven Tey83a1d91b5a3a
diff --git a/apps/web/lib/middleware/link.ts b/apps/web/lib/middleware/link.ts
index 9ef71fc255..086e2a25a3 100644
--- a/apps/web/lib/middleware/link.ts
+++ b/apps/web/lib/middleware/link.ts
@@ -51,6 +51,19 @@ export default async function LinkMiddleware(
key = "_root";
}
+ // we don't support .php links (too much bot traffic)
+ // hence we redirect to the root domain and add `dub-no-track` header to avoid tracking bot traffic
+ if (key.endsWith(".php")) {
+ return NextResponse.redirect(new URL("/", req.url), {
+ headers: {
+ ...DUB_HEADERS,
+ "X-Robots-Tag": "googlebot: noindex",
+ "dub-no-track": "true",
+ },
+ status: 302,
+ });
+ }
+
let link = await redis.hget<RedisLinkProps>(domain, key);
if (!link) {
@@ -65,6 +78,7 @@ export default async function LinkMiddleware(
...DUB_HEADERS,
"X-Robots-Tag": "googlebot: noindex",
},
+ status: 302,
});
} else {
return NextResponse.rewrite(new URL("/notfoundlink", req.url), {
@@ -161,6 +175,7 @@ export default async function LinkMiddleware(
...DUB_HEADERS,
...(!shouldIndex && { "X-Robots-Tag": "googlebot: noindex" }),
},
+ status: 302,
});
} else {
return NextResponse.rewrite(new URL(`/expired/${domain}`, req.url), {