I have WHMCS installed in a subdomain (clients.example.com) on a shared hosting account using cPanel and am using a wildcard SSL which (under cPanal) always ends up serving the page from the main directory. Consequently, I have a .htaccess rewrite rule redirecting *.example.com to the appropriate directory (in this example, clients.example.com):
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/.+\.example.com/
RewriteCond %{HTTP_HOST} ^([0-9a-zA-Z]+.example.com)
RewriteRule ^(.*)$ /%1/$1 [NC,L,NS]
Many of the templates generate links using "{$smarty.server.PHP_SELF}" which, I assume, comes from _SERVER["PHP_SELF"]. Herein lies my problem. The value for _SERVER["PHP_SELF"] is different for the non-redirected (http:) vs. the redirected (https:) executions. For https:, _SERVER["PHP_SELF"] contains the subdomain's host name at the beginning while the http: version does not.
As an example, to add a product, I go to "http(s)://clients.example.com/cart.php?...". The shopping cart form is created with
action="{$smarty.server.PHP_SELF}?a=confproduct&i={$i}"
. The end result is the http: version of the form contains "action='/cart.php?...'" while the https: version of the form contains "action='/clients.example.com/cart.php?...'". When the client clicks on "Add to cart", the http: version correctly maps to "http://clients.example.com/cart.php?...". But, the https: version maps to "https://clients.example.com/clients.example.com/cart.php?..." instead of "https://clients.example.com/cart.php?...".
I know the different values in _SERVER["PHP_SELF"] are a result of the .htaccess rewrite (which I know of no way around in this shared hosting environment). So, my dilemma is how do I correct these links?
I was thinking if there was an exit that would allow me to change the output html before it was sent, I could replace all occurrences of "/clients.example.com/" with "/" (or further restrict it to replace "action='/clients.example.com/" with "action='/"). But, I have no clue how I might intercept WHMCS html output before it gets served back to the client.
Another approach might be to find a way to change the value of "{$smarty.server.PHP_SELF}" to not include the subdomain's host name. Again, I have no idea how I might do this globally.
Does anyone have any thoughts on how I might correct this without rewriting all of the templates?
Thanks in advance.