Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i want to open my website login page with https only, i check that SSL is enable on server here is basic information of server return by phpinfo();

    PHP Version 5.2.14
Configure Command   '--with-openssl'  '--enable-zip' 
Registered Stream Socket Transports     tcp, udp, unix, udg, ssl, sslv3, sslv2, tls 
cURL support    enabled
cURL Information    libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.2.3
OpenSSL support     enabled
OpenSSL Version     OpenSSL 0.9.7a Feb 19 2003

my basic code on header.php is

if($_SERVER['SERVER_PORT'] != 443) {
   header("HTTP/1.1 301 Moved Permanently");
   header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);

but it always give below error:
The connection has timed out
The server at www.mywebsite.com is taking too long to respond.

although same code works perfectly at localhost...where phpinfo() returns

PHP version 5.3.1
OpenSSL support     enabled
OpenSSL Library Version     OpenSSL 0.9.8l 5 Nov 2009
OpenSSL Header Version  OpenSSL 0.9.8l 5 Nov 2009

i have 2 Questions

  1. Do i need to update my SSL?? or how do i run website on https on server???
  2. How to open only 2 pages in https and rest of all in http


share|improve this question

migrated from stackoverflow.com Feb 7 '11 at 8:37

This question came from our site for professional and enthusiast programmers.

Whether your site is served over SSL or not has nothing to do with whether PHP has the openssl module. It's a web server (Apache/IIS) level protocol and gets configured there. Search the web or serverfault.com –  Dan Grossman Feb 7 '11 at 7:04
so how do i make my web to open directly in https??? –  diEcho Feb 7 '11 at 7:08
In Apache, you configure mod_ssl, tell the server to listen on port 443, create a virtual host entry for port 443 and this hostname, specify the locations of a private key and signed SSL certificate file (which you bought from an SSL certificate provider), restart the web server... –  Dan Grossman Feb 7 '11 at 7:12
@Dan in which file have to write , will u plz xplain it on Answer section –  diEcho Feb 7 '11 at 7:18
This is not on-topic for StackOverflow, it's server configuration not programming, and you can find a million tutorials on the web. –  Dan Grossman Feb 7 '11 at 7:19

1 Answer 1

up vote 0 down vote accepted

A site which times out remotely, but which works when accessed via localhost, usually means that a firewall is misconfigured. Check that port 443 is open from the outside world.

share|improve this answer
var_dump($_SERVER['SERVER_PORT'] == 443) returns false, how do i enable?? –  diEcho Feb 8 '11 at 4:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.