0

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.

2
  • Taking a step back... why do you need a reverse proxy when you appear to be working on a single server in the same filespace? It looks like all your subdomains are pointing to different areas (different subdirectories?) with their own "hardcoded" .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 the site URL parameter? - your PHP script can already see the subdomain via the requested hostname.
    – MrWhite
    Oct 31, 2019 at 18:10
  • I agree the site parameter does seem a bit pointless now you mention it. The main domain will be the admin page for everything, and the subdomains will have their own data, logos etc. The hope for this method makes things a bit easier in my mind when I start working on it, instead of making a mess when including ../public_html/files..... In the end when another site (ie site3, site4, site5 etc) is added in the future, just create the folder, pop in the autogenerated .htaccess and it is live - If this makes sense Oct 31, 2019 at 20:58

0

You must log in to answer this question.

Browse other questions tagged .