How to remove the :port number from the end of an

2020-07-13 12:08发布

问题:

In IIS, I noticed when you use the default ports (80 for http and 443 for https) the port number doesn't display at the end of the URL in your browser. However, if you use a different port it will display.

Example: Default port generates link: http://www.example.com

Custom port generates link: http://www.example.com:8301

Is there a setting you can change to make the port (in this case, :8301) not display without using the defaults?

回答1:

80 is a default port for HTTP connections. http://example.com = http://example.com:80

443 is a default port for HTTPS connections. https://example.com = https://example.com:443

If you are hosting on an other port, you have to include it in the URL.
It's not a IIS rule - it's about HTTP in general. You cannot configure the server in such way that http://example.com will work with port 8301 and I can't imagine any situation when it can be useful. I strongly believe that 80 port is chosen by default on a browser-side but not assigned on a server-side.

If you want users to reach this website by http://example.com URL and it must be a main page then swap your 8301 and 80 ports WebSites' bindings.



标签: url iis port