I'm on a shared host, so can only do redirects via htaccess, but the plan is to have multiple subdomains (each with a letsencrypt certificate issued via cPanel) to point to a universal set of php files within a folder of the main domain using a ?site= variable to differentiate. I'm also using the [P] flag to keep the user from knowing they have been redirected and hide the ?site= variable.
The subdomains are created via cPanel, and then issued a LE SSL certificate;
example.com - Will contain the admin page, with a folder for the subdomains site1.example.com - Points to example.com/folder/?site=site1 site2.example.com - Points to example.com/folder/?site=site2
I've gotten this to work prior to https'ing everything with (site1's .htaccess - site2, site3 etc will be the same but site= changed);
RewriteEngine on
RewriteRule ^(.*)$ http://example.com/folder/$1?site=site1&%{QUERY_STRING} [P]
But changing the Rule to https:// gives 500 Internal Server Error. Changing the [P] to [L] works but displays the updated url to the user.
No errors seem to appear in cPanel's Errors page, making debugging difficult.
Is this even possible with mod_rewrite and https? Or should I cut my losses and keep the files in each subdomain for ease.
.htaccess
file - directing the request back to the main domain? Why not have them all point to the same place as the main domain and have a single.htaccess
file? And why do you need thesite
URL parameter? - your PHP script can already see the subdomain via the requested hostname.