Resolving the issue of css and images not being loaded while redirecting with httpd.conf

Posted on Updated on

After successful virtual hosting and redirecting my application, the redirection worked but the stylesheet(css) and images did not get loaded. For virtual hosting  check my post on Virtual Hosting in windows using Apache 2.4.4.

Everything was mapped correctly but one entry was left out. Firstly, i had just added the following line:

ProxyPass  /myApp      http://localhost:8080/myApp/
ProxyPassReverse /myApp      http://localhost:8080/myApp/

With the above mapping it loads the root file(index.jsp) but does not load the css and images. So to load everything i added the following line:

ProxyPass /   http://localhost:8080/myApp/
ProxyPassReverse /      http://localhost:8080/myApp/

 

I hope you could find the difference. In the above line, it is mapped with the application name i.e myApp after the ProxyPass and ProxyPassReverse (/myApp). So it was loading the index.jsp page but not the images and the css. But in the second line i have just left with a frontslash(/) after ProxyPass and ProxyPassReverse instead of /myApp, because frontslash(/) points to the root of the directory. So everything gets loaded.

For a virtual hosting to work, both the above code has to be added. It will not work independently. So the final redirection code will be:

<VirtualHost *:80>

ProxyPass  /myApp      http://localhost:8080/myApp/
ProxyPassReverse /myApp      http://localhost:8080/myApp/

ProxyPass /   http://localhost:8080/myApp/
ProxyPassReverse /      http://localhost:8080/myApp/

</VirtualHost>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s