Using the active protocol


I’ve been wondering how its possible to make a link to other domain with the current active protocol?

For instance:

Users comes to and he posts a form:

  1. he is on so form should post

  2. he is on (SSL) so form should post to

Is there any way to set form post action to “://” so that browser would automatically use the current used protocol (http or https) accordingly?

Thanks for help


I believe that this is a PHP question …

… where I would have the form’s script fetch Apache’s {HTTPS} variable OR {SERVER_PORT} variable (using $_SERVER[‘HTTPS’] or $_SERVER[‘SERVER_PORT’]) and test for on/null or 80/443 and add the “s” to http in the action accordingly.