简体   繁体   中英

apache rewrite rule for URL

My java application is deployed on tomcat and i am using rewrite rule from apache to access the application using apache. My application name is my.war deployed on tomcat/webapps/my/

i am using following rewrite rule in httpd.conf

    RewriteEngine On
    ProxyPreserveHost On

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

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

when i open www.mydomain.com/ it changed the url to www.mydomain.com/my/ i don't want this , i want the url be www.mydomain.com/ and it should open the landing page of my application.

您应该改用mod_proxy的ProxyPass

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

You need to install the application as your "ROOT" application on tomcat. Tomcat will automatically make that .war the base URL when you land on tomcat. To do this, just rename your "my.war" to "ROOT.war" and redeploy it.

Note, on some Tomcat instances, there will be a pre-installed default "ROOT" application for managing some Tomcat settings and apps via a web UI. Deploying your own ROOT.war will naturally replace this utility.

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