Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Redirect multiple sub domains query

Discussion in 'General Discussion' started by Mick Young, Sep 8, 2018.

  1. Mick Young

    Mick Young Registered

    Joined:
    Sep 8, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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]
     
  2. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,262
    Likes Received:
    481
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    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”.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    Jeff P. likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice