*domain.com subdomain wildcards

Re. Using Wildcards in Page Rules

Really useful to be able to catch both the domain and subdomains in one go.
But the problem is on subdomains the dot is caught.

For the rule: *domain1.comdomain2.com/$1
e.g. sub.domain.comdomain2.com/.sub (note the dot/period before ‘sub’)

Is there any way of dealing with this?

*domain1.com/* -> https://domain2.com/$2

The article actually addresses that.

@domjh provides exclusively high-quality tutorials :+1:t2:


Granted it’s a great tutorial, and the redirect ‘works’, but as my specific example shows it unfortunately carries the dot/period with it into the $1.

Is there any way of stripping the #?

How manipulable are the $1 objects?


Ehm, I just posted that in my previous reply :slight_smile:

I must be being slow:

could you please repeat again the specific bit about stripping the period from the end when you utilise $1 ?

Much appreciated!

Here we go.

Hang on, do you actually want the hostname to be part of the path?

So www.domain1.com should redirect to domain2.com/www? In that case the original rule would have been actually correct, but there shouldn’t be a leading period in the first place.

In that case you’d need the following, in order not to include the separating period in your match

*.domain1.com -> https://domain2.com/$1

Note, this will not work for the naked domain, but as there won’t be a hostname, there won’t be anything to match anyhow.

Yeah I switched the subdomain to be a subfolder.

Acchhh: like you say, it seems the only solution is for a specific *.domain1.com, but then you don’t get the benefit of carrying the domain1.com redirect with it.
As I’m limited to 3 (free) redirects, I will have to abandon this sub redirect. Sorry ma.w4rner.com (now at w4.rner.me/ma) !!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.