So looking at the above, we need showthread.php? to be /community/threads. AND the number at the end of php? need to be appended to the end of the URL. Bear in mind that this number will change depending on the thread so whatever that number of it needs to be put at the end.
So similar to the above we need any request going to member.php?638048-testuser to be /community/members/testuser.638048/
Also as these are usernames there will be many so any request for member.php… redirects to /community/members/…/
We have a business account ( ive already lodged a ticket ) so have more rules than pro. I hope all that makes sense.
Im sorry but this is why we pay for a business plan.
Business plan
Designed for business-critical websites and applications. It gives you the highest level of control and customization of all self-serve plans, plus 100% uptime SLA and prioritized ticket support.
If you need solutions engineering, that’s for Enterprise customers. Tickets are for troubleshooting:
Documentation and Community are for helping users learn how to use Cloudflare, which is why I recommended the Wildcard approach, and provided a link to the documentation.
If you need help writing RegEx, I recommend trying ChatGPT, or similar. Your examples look to be pretty straightforward, and I’ve found ChatGPT to be quick and easy for this. Here’s more info on regex_replace for a Dynamic Single Redirect:
We couldnt get it to work with redirect so we use Cloudflare Workers which works .
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let url = new URL(request.url)
// Check if the URL matches the old pattern
if (url.pathname.startsWith("/showthread.php")) {
let query = url.searchParams
let fullQuery = query.toString() // Full query string (e.g., 2875401-why-dont-the-old...)
// Extract thread ID and title from the query string
let match = fullQuery.match(/^(\d+)-(.*)$/)
if (match) {
let threadId = match[1] // Capture group 1: Thread ID
let threadTitle = match[2] // Capture group 2: Thread title
// Construct the new URL
let newUrl = `https://www.example.com/community/threads/${threadTitle}.${threadId}`
// Redirect to the new URL
return Response.redirect(newUrl, 301)
}
}
// If no match, return original request
return fetch(request)
}