java 如何从 Tomcat url 中删除端口号?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26513503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 10:02:53  来源:igfitidea点击:

How do I remove the port number from Tomcat urls?

javatomcatdnstomcat7linode

提问by Chris

Please help!

请帮忙!

How do I remove the port number and application name from Tomcat URL's?

如何从 Tomcat URL 中删除端口号和应用程序名称?

I have my domain with GoDaddy and hosting with Linode.com. I installed Tomcat into Linode, uploaded my website files and pointed my domain from GoDaddy to my IP address with Linode but I can't figure out how to remove both the port number and the application name so it is just www.mywebsite.com.

我在 GoDaddy 拥有我的域名,并在 Linode.com 上托管。我将 Tomcat 安装到 Linode,上传我的网站文件并将我的域从 GoDaddy 指向我使用 Linode 的 IP 地址,但我无法弄清楚如何删除端口号和应用程序名称,所以它只是 www.mywebsite.com。

Anyone know how to do this? I really appreciate your help!!!

有人知道怎么做吗?我真的很感谢你的帮助!!!

回答by sventschui

Change Port:

更改端口:

See http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/

http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/

in server.xml of your tomcat find

在你的 tomcat 的 server.xml 中找到

<Connector port="8080"

and replace with:

并替换为:

<Connector port="80"

(Similar for HTTPS, Search for 8443 replace with 443)

(类似HTTPS,搜索8443替换为443)

Context Root:

上下文根:

Simply deploy your web app named ROOT.war and it will be deployed to context root "/"

只需部署名为 ROOT.war 的 Web 应用程序,它将被部署到上下文根“/”

(my-webapp.war would result in /my-webapp)

(my-webapp.war 将导致 /my-webapp)

回答by Srinivasu

1.Run the tomcat in the port 80 {HTTP port} 2.Change the application context path to ROOT and rename the already existed ROOT to some other name

1.在80端口{HTTP端口}运行tomcat 2.将应用程序上下文路径更改为ROOT并将已经存在的ROOT重命名为其他名称