Reputation: 73
I have various web application running on my apache server.
I can access the first web app by using http://localhost:8080/app1/login
But within the login page, I am trying to access an image, login.png as "/images/login.png". This tries to get the images from the default web app and not the web app on which it is currently working from.
I do not want to change the default web app of apache. Is there a way that I can access the image like "/images/login.png" and not as "/app1/images/login.png" or "../images/login.png"
Upvotes: 0
Views: 582
Reputation: 451
Or if you want to use a RewriteRule add this to your webserver roots .htaccess. This checks if the Requested filename is not a physical file or directory. if it's not. it redirects to your /app directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/images/(.*) /app1/images/$1 [L,QSA]
</IfModule>
Upvotes: 2
Reputation: 4579
well if you are using it in html... then
./images/login.png
EDIT: Sorry I didnt see that you dont want to use that path... as other option can be using modRewrite... you can rewrite your paths... so if you will use /login/image.jpg that can apache automatically rewrite for you as ./login/image.jpg
Upvotes: 0