Redirect multiple sub domains query

Mick Young

Registered
Sep 8, 2018
1
0
1
United Kingdom
cPanel Access Level
Root Administrator
Good day to you all,

I recently bought a domain lets say for eg fo###-#####.com it has a large amount of subdomains around 350,

I wanted to re-direct all the subs to the root domain, I have had a look at the .htaccess of the /public.html folder and it contains this.

Could one of you clever people tell me what this below means in terms of redirecting and if it is redirecting does it transfer the sub domains authority to the root domain?

Thank you in advance.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
RewriteCond %{HTTP_HOST} ^\*\.fo###\-####\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.\*\.fo###\-#####\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/www\.fo###\-#####\.com" [R=301,L]
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,271
313
Houston
Hi @Mick Young

This portion:

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Is the wordpress redirect which mostly handles how your permalinks are displayed

For this portion

Code:
RewriteCond %{HTTP_HOST} ^\*\.fo###\-####\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.\*\.fo###\-#####\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/www\.fo###\-#####\.com" [R=301,L]
These two lines handle an exception for AutoSSL
Code:
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
So for this purpose they're unimportant.

It looks like this portion here redirects *.domain.tld and www.*.domain.tld is redirected to www.domain.tld
Code:
RewriteCond %{HTTP_HOST} ^\*\.fo###\-####\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.\*\.fo###\-#####\.com$
RewriteRule ^/?$ "http\:\/\/www\.fo###\-#####\.com" [R=301,L]
^
Denotes the beginning of a regex (regex = regular expression) test string. That is, begin an argument with the proceeding character.
\
Escapes special characters ( ^ $ ! . * | ). For example, use \. to indicate/escape a literal dot.

*
Matches zero or more of the preceding character. For example, you can use .* as a wildcard to match anything (or nothing).

\.
Indicates a literal dot (escaped).

^domain\.com$
Defines the exact string, “domain.com”.
 
  • Like
Reactions: Jeff P.