I am creating an html5 - JavaScript application (for mobile products, using PhoneGap). I must communicate with a Relaxation service.

The services are now running on "http://localhost:8080/backend/mvc/"

I am developing my application with an wamp server (apache2) (http://localhost/stage/) I am using Chrome for browser.

when preforming en ajax call the browser responds: XMLHttpRequest cannot load http://localhost:8080/backend/mvc/event. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

And So I find a number of ways to circumvent this mix-domain ajax call problem:

1) beginning chrome chrome.exe --disable-web-security => no difference 2) setting up apache using mod_proxy to redirect the trafic.

I enabled within the httpd.conf:


I put b .htaccess file within the www root using the following content:

# start mod_rewrite
RewriteEngine On

ProxyRequests off
    Order deny,allow
    Allow from all

ProxyPass /EMBackend/ http://localhost:8080/backend/mvc/
ProxyPassReverse /EMBackend/ http://localhost:8080/backend/mvc/
RewriteRule ^/EMBackend/(.*)$ /backend/mvc/$1 [R]

I restarted all services (apache,php,..)

leading to error 500

apache error log: [Tue Oct 18 14:30:11 2011] [alert] [client] C:/wamp/www/.htaccess: ProxyRequests not allowed here

Any clues regarding how to resolve this?

found a functional solution:


LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

Put this within the primary portion of your configuration (or preferred virtual host, if using Apache virtual hosts):

ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
    Order deny,allow
    Allow from all

ProxyPass /EMBackend http://localhost:8080/backend/mvc
ProxyPassReverse /EMBackend http://localhost:8080/backend/mvc
<Location /EMBackend>
    Order allow,deny
    Allow from all

And So I guess I can not place it in .htaccess or I needed to set ProxyPreserveHost On. I put Include conf/extra/ within the httpd.conf file and produced the httpd-proxy.conf file and set the script above inside it. Restarted apache and it is working!