简体   繁体   中英

404 Error while using https with php script

I am developing some php script that works fine if I access it by http. But while I try to access it via https prefix server returns 404 Error. What I am doing wrong here?

Depending on the webserver, the error_log (nginx/apache/apache2) directive and where it is logging errors to, will help you understand where the problem is happening. 404 indicates that the file does not exist or the permissions are not set properly for the webserver to serve it. As it's only happening with HTTPS, chances are as hakre suggested, your HTTPS server may not be using the same document root as HTTP.

Posting information about the type of webserver, what, if anything, shows in the error logs, will help everyone at stackoverflow.com understand better your problem, and propose an appropriate answer.

Name based virtual hosting will not function properly with HTTPS. You can have 1 virtual host for 1 IP address with HTTPS: http://wiki.apache.org/httpd/NameBasedSSLVHosts

As a rule, it is impossible to host more than one SSL virtual host on the same IP address and port. This is because Apache needs to know the name of the host in order to choose the correct certificate to setup the encryption layer. But the name of the host being requested is contained only in the HTTP request headers, which are part of the encrypted content. It is therefore not available until after the encryption is already negotiated. This means that the correct certificate cannot be selected, and clients will receive certificate mismatch warnings and be vulnerable to man-in-the-middle attacks.

In reality, Apache will allow you to configure name-based SSL virtual hosts, but it will always use the configuration from the first-listed virtual host (on the selected IP address and port) to setup the encryption layer. In certain specific circumstances, it is acceptable to use a single SSL configuration for several virtual hosts. In particular, this will work if the SSL certificate applies to all the virtual hosts.

Please check and double-check your server configuration - especially the DocumentRoots.

It is possible to use SSL on NameBasedVirtualHosting using SNI (Server Name Indication - a relativly new TLS extension).

SNI is supported by most major servers and nearly all clients.

Apache2 supports it since version 2.2.12, Apache with backport patch, nginx, lighthttpd and cherokee are supporting it off the bat.

See: http://de.wikipedia.org/wiki/Server_Name_Indication for a few more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM