Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm currently facing interesting problem which I cannot resolve. I have an Apache2 as a proxy to Tomcat. The proxy configuration looks like:

<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>

ProxyRequests       Off
ProxyPreserveHost   On
ProxyPass           /myApp       http://localhost:8080/myApp
ProxyPassReverse    /myApp       http://localhost:8080/myApp

Everything works fine, the problem come with AJAX within my application. When I go to myApp url: http://myurl.com/myApp I can access ajax only using the same url. When I use www url prefix (http://www.myurl.com/myApp) for AJAX the ajax content is not loaded (apache logs HTTP 302). This also doesn't work vice versa. I'm pretty sure that I can correct it in Apache, but I don't know how. Do you have any suggestion?

Thanks for any help,

Mateo

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Pick one host name to be canonical and redirect to it from the other.

e.g. (If I'm remembering my Apache syntax right)

<VirtualHost *:80>
    ServerName example.com
    Redirect 301 / http://www.example.com/
</VirtualHost>

Alternatively (or additionally). Use root relative URIs (i.e. those which start with /foo instead of http://example.com/foo) so that requests stay on the same host.

share|improve this answer
    
The "alternatively" suggestion helped. I didn't know that it will work like that. Thanks for your help!:-) –  mateo Dec 1 '10 at 19:35

Do you have some .htaccess for redirection ?

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.