How to create subdomains programmatically with PHP, htaccess on WordPress site [closed]

15 hours ago 1
ARTICLE AD BOX

I want to setup subdomains programmatically:

subdomain.my-domain-name.com -> my-domain-name.com/subdomains.php?subdomain=subdomain

CloudFlare settings:

Type: A
Name: *
Content: 255.255.255.255 (IPv4 example)

Type: CNAME
Name: www
Content: my-domain-name.com

Type: A
Name: my-domain-name.com
Content: 255.255.255.255 (IPv4 example)

.htaccess:

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^(^[a-z][a-z-]+)\.my\-domain\-name\.com$ RewriteRule ^([a-z-]+)$ subdomain.php?subdomain=%1 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase /RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

I want to hit:

subdomains.my-domain-name.com
sub-domains.my-domain-name.com

Note: My domain use two hyphen.

Every time I make a request I get the cPanel page error.
SORRY
If you are the owner of this website, please contact your hosting provider.

What I'm doing wrong?

Read Entire Article