Discussion on whether the host has a port

Source: Internet
Author: User
Whether the host contains a port or not. $ _ SERVER ['http _ host'] obtains a HOST with a port number. Theoretically, the host is a host name and should not contain a port number.


Reply to discussion (solution)

$ _ SERVER ['http _ host'] does not contain a port number
$ _ SERVER ['server _ port'] is the PORT number.

$ _ SERVER ['http _ host'] does not contain a port number
$ _ SERVER ['server _ port'] is the PORT number.
In this test, if port 80 is not used, $ _ SERVER ['http _ host'] carries a port number.

Take a good look at the global variable $ _ server of php.
Reference link:
Php URL retrieval method (global variable)
Http://www.jbxue.com/article/6798.html

$ _ SERVER ['http _ host'] will contain the HOST header field of the request header in HTTP.

Host header domain

The Host header specifies the Intenet Host and port number of the requested resource, which must represent the location of the original server or gateway of the request url. The HTTP/1.1 request must contain the host header domain; otherwise, the system returns the status code 400.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.