Identical subdomain redirects

Hi there, I am in the middle of a big site move and I would like to redirect many links if possible to my subdomain.

There are hundreds of links out there on my main domain tayloryourbestlife.com/////* (the stars are variables)

What I would like to do is somehow, forward the links to the exact same link on my submdomain, mab.tayloryourbestlife.com/////* …

I can’t do a full redirect because I have links like tayloryourbestlife.com/mab/review that will be in use in the new site, but longer affiliate links with 3 4 or 5 /s need to be redirected to the new MAB subdomain.

I set up some page rules, but it doesn’t seem to be working. Is there any way around this please?

It seems you have used * both in the origin and target URL.

Instead, try this:

example.com/*/*/*/*/*
example.com/$1/$2/$3/$4/$5

Thank you, it seems to be redirecting now, but for some reason it seems to be rerdirecting back in an endless loop.

https://tayloryourbestlife.com/sc-bridge/r/product-version/DgiBXPYQEEWw87AF/XMc66C5kywpQShEB

May I ask, are the app paths so specific case to have so much both all between and slashes exact and you have to match all of them each?

The asterisk covers slashes as well - one * would be enough and match anything behind, or not?

1 Like

I am not sure, I am just kind of trial and erroring.

I need the first few to direct to the current site, it is only after 3 /s or more I need to redirect to the subdomain.

Perhaps the redirect loop is created because the origin URL is the root domain. Try to prefix it with the scheme and see if it works (it should):

https://example.com/*/*/*/*/*
https://sub.example.com/$1/$2/$3/$4/$5

Actually, not. You can do patterns such as *str*str in Page Rules

2 Likes

Thanks for your help so far.

Sadly it does not seem to have worked

It did work! It just took a little while for it to implement. I think it may have been cached for me from before. All seems to be ok now though, thanks so much for all your help!

1 Like

Can you provide a curl command which shows it not working. Right now the hostname is :grey:, but I can simulate requests to :orange: and the redirects seems to work as expected:

% curl https://tayloryourbestlife.com/1/2/3/ --dump-header - --silent -o /dev/null --connect-to ::172.66.40.133 |egrep -i 'http/|location'
HTTP/2 301
location: https://mab.tayloryourbestlife.com/1/2/3/
% curl https://tayloryourbestlife.com/1/2 --dump-header - --silent -o /dev/null --connect-to ::172.66.40.133 |egrep -i 'http/|location'
HTTP/2 404

You only need the third Page Rule. The other two are essentially redundant, the last * in the three star Page Rule will match everything that comes after the last /.

2 Likes

I’m sorry I don’t know how to provide a curl command

It has half worked so far.

This Cheetah is working fine and redircting as expected>

However, https://tayloryourbestlife.com/sc-bridge/r/product-version/Q3S13uNYSFMgTrsy/Qyaosc0AZTWaA533 Is not working and still giving me the redirect error.

I have removed the other redundant rules as you suggested

Everything just started working for some reason, I have not changed anything!

1 Like

Unfortunately, now I have a new issue.

It seems that all the elements and scripts with extensions with more than 3 /s are now getting redirected! facepalm

I’m a bit lost here because yesterday your site didn’t seem to be a WordPress installation, but today it does!

Anyway, you can prevent the redirect for most assets by creating page rule with any directive and placing it above the one that redirects the subdirectories:

URL: /wp-*
Setting: Auto Minify: Off

(It could be any setting that doesn’t interfere with your website performance)

There may be a few other assets on your domain that do not start with /wp-, and for those you’d need to add aditional page rules to avoid these URLs from being redirected.

1 Like

Thanks so much!

Yes, I was moving my main site from Builderall to Wordpress :slight_smile:

1 Like