URL 的 apache 重写规则

标签 apache tomcat mod-rewrite url-rewriting

我的 java 应用程序部署在 tomcat 上,我正在使用 apache 的重写规则来访问使用 apache 的应用程序。 我的应用名为my.war,部署在tomcat/webapps/my/

我在 httpd.conf 中使用以下重写规则

    RewriteEngine On
    ProxyPreserveHost On

    RewriteRule ^/$  \
    http://localhost:8082/my [P]

    RewriteRule ^/(my/.*)$  \
    http://localhost:8082/$1 [P,R,L]

当我打开 www.mydomain.com/时,它将 url 更改为 www.mydomain.com/my/ 我不想要这个,我想要 url 是 www.mydomain.com/并且它应该打开我的应用程序的登录页面。

最佳答案

您应该改用 mod_proxy 的 ProxyPass:

ProxyPass / http://localhost:8082/my/

关于URL 的 apache 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21255022/

相关文章:

tomcat - 如何在servlet中使用spark集群计算功能

apache - 在 htaccess 中屏蔽 URL 重写

.htaccess - 配置文件系统的重写规则

java - HWPFDocument 位于哪里?我在 POI 项目中找不到它

php - 获取文件目录的 URL 路径 (PHP)

php - 无法将mysql_connect识别为功能/PHP,未在Apache中连接到MySQL

html - 从 mod_autoindex 中删除最后修改时间和大小

java - 使用 Javabeans 创建登录页面(未设置属性)

eclipse - HTTP 状态 [404] ? [Not Found](源站没有找到当前表示)

php - .htaccess seo 重写