Hello
I have cloudflare worker recipe for redirecting visitor from some country to another subdomain ,
i need to redirect the visitors with keeping on requested link like if the user request url like [login to view URL]
to be like
[login to view URL]
my current recipe worker code is :
-----------------------------------------------------------------------------------------------------
async function handleRequest(request) {
return redirect(request, 'subdomain')
}
addEventListener('fetch', event => {
[login to view URL](handleRequest([login to view URL]))
})
/**
* Returns a redirect determined by the country code
* @param {Request} request
*/
function redirect(request) {
// The `cf-ipcountry` header is not supported in the previewer
const country = [login to view URL]('cf-ipcountry')
const url = countryMap[country]
return [login to view URL](url)
}
/**
* A map of the url's to redirect to
* @param {Object} countryMap
*/
const countryMap = {
"us" : "[login to view URL]",
"uk": "[login to view URL]"
}
-----------------------------------------------------------------------------------------------------
this is redirect users to defined subdomain and i have tried some variables at the end like htaccess redirect :D but its not working any way i need to customize the code to redirect to the requested url with changing www to the subdomain based on defined country's in the recipe .
Thank You
Hi, I think I've already seen the issue and I can fix it in less than 1 hour.
I've started working with cloudflare workers when they came out and I've had many projects with them before on freelancer.
Write to me in chat if you are interested and I'll fix the issue with your worker.
$30 USD på 7 dage
5,0 (9 anmeldelser)
3,6
3,6
3 freelancere byder i gennemsnit $28 USD på dette job
Hi sir, I have read your description, I am an experienced Wordpress developer and expert at Wordpress website speed optimization. feel free to contact me!