la***********@zipmail.com wrote:
http://mine.com/myscript.php
and I want to call
https://mine.com/secure.php. Without hard coding the domain, how can I
incorporate "https"? Right now, I'm trying
action="<?php print "https://" . $_SERVER['SERVER_NAME'] .
"/secure.php"; ?>
but the resulting url is
https://www.mine.com/secure.php
Take a look at the output of phpinfo(32); Probably HTTP_HOST contains
the requested mine.com, else you have to strip like already suggested.
BTW I'd make the page that submits to an https url, itself https also. I
personally will not submit confidential info unless I know it will be
transmitted secure, if the form is on a http URL I'd hae to check the
source to find out what will happen.
Also that makes it possible to use a relative link, and since there is
nothing posted yet you can very easily force myscript.php to be a https
URL. If you are using apache the following will make it even more easy:
RewriteRule ^/(.*):SSL$ https://%{HTTP_HOST}/$1 [R,L]
RewriteRule ^/(.*):NOSSL$ http://%{HTTP_HOST}/$1 [R,L]