I can't believe the trouble I had doing this, and the amount of time wasted. Many of the solutions I found online did not work because either virtual hosting wasn't taken into consideration or they ended in recursion.

Here's the problem: I want everyone who comes to www.mydomain.com/secdir to use https, not http. Http is okay everywhere else within my domain, but not in secdir.

I couldn't find a solution in PHP at first, but now that I've found the .htaccess solution, I can see that the concept will port over to PHP quite easily. I'll leave that solution for someone else to post. The .htaccess solution follows:

RewriteEngine  on
RewriteCond  %{SERVER_PORT}  !443
RewriteRule  ^.*$  https://www.mydomain.com/secdir/
And if your server doesn't use the default 443 port for https, make the following two changes (where XXX is the port number your server uses for https):

RewriteEngine  on
RewriteCond  %{SERVER_PORT}  !XXX
RewriteRule  ^.*$  https://www.mydomain.com:XXX/secdir/
I hope this helps someone. God bless!

Warren Gaebel, B.A., B.C.S.