Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I am trying to remove the context name from the URL of my server.

Current URL - http://www.domainname.com/MyApp/

What I need to make is to make it available at - www.domainname.com/

So it is only going to host one main app and that needs to be displayed when we open www.domainname.com/ on browser.

I have already tried couple of things like below -

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(Context/.*)$
RewriteRule ^/(.*)$ /Context/$1 [P,L]

OR

redirect permanent /MyApp/ abcd://domainname.com

OR

Using JKMount -

JkMount /MyApp/* ajp13
JkMount /MyApp* ajp13

OR

Deploy war file to ROOT of tomcat and make relevant chagnes in web and server.xml All of these aren't working and I keep getting a intenal error. I need a way to basically trim the tomcat URL to make short.

share|improve this question
    
Is there a link with "www.domainname.com/"? I mean do you plan to do other rewrite rules for other domains that will use your app too? –  Olivier Pons Nov 19 '11 at 6:27
add comment

migrated from serverfault.com Feb 21 '11 at 21:42

This question came from our site for professional system and network administrators.

2 Answers

Assuming that http://www.domainname.com/MyApp/ works as is... shouldn't you be able to just use your final RewriteRule? Just drop the RewriteCond and the 'P' flag.

Or if you're going to use mod_rewrite to do the proxy with the 'P' flag, don't you need to use the full URL in the RewriteRule? Something like http://tomcatserver:tomcatport/Context/$1

share|improve this answer
    
@matthew Thanks Matthew though I did try with following as per your suggestion though it doesn't seem to have worked out - RewriteRule ^/(.*)$ /Foldername/$1 [P] Instead of (.*), I used following - RewriteRule ^/(/.*)$ /GroupAGWeb/$1 [P] OR RewriteRule ^/(abc-xyz.paint-domain.com.*)$ /Foldername/$1 [P] –  Redbull Fan Feb 18 '11 at 4:52
    
I don't think you want the P flag. If you've set up the Proxy with Mod_jk I don't think you also need to tell mod_rewrite to do the proxy. –  matthew Feb 21 '11 at 12:38
add comment

You should stop using mod_jk and start using mod_proxy. I run tomcat on port 8080. The web app that powers my site has an internal url like http://localhost:8080/mysite I use mod proxy to make it available at http://mysite.example.com/ I use a firewall to ensure that only port 80 is accessible from the outside world. mod_proxy is much more flexible than mod_jk. Tomcat makes application available both http port 8080 and through the ports that mod_jk uses by default, so you likely won't even have to change your tomcat settings.

My apache configuration looks like this for that site

<VirtualHost *:*>
    Servername mysite.example.com
    ProxyRequests Off
    ProxyPass / http://localhost:8080/mysite/
    ProxyPassReverseCookiePath /mysite /
    ProxyPassReverseCookieDomain localhost mysite.example.com
</VirtualHost>

The cookie stuff is so that session cookies get translated by mod_proxy correctly. You can also have mod_proxy rewrite the links if you need to. In my case, my web app handles that.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.