I have the current situation in my web application:
The html files, will request images from the let’s say {currentpath}/images/
Because of using an MVC my URL’s change often:
domain.com/app/main/welcome/
(to get the welcome method from the main class)
In this situation, the view will request images from
domain.com/app/main/welcome/images/
I would need that in any situation, if a script calls for something from it’s images subfolder, to be redirected to a fixed folder (let’s say domain.com/app/images/).
So far, I have tried this:
RewriteRule ^(.*)/app/(.*)/images/(.*)$ $1/app/images/$3 [R=301,L,QSA]
Which doesn’t work.
My intention is to redirect:
domain.com/app/{anything}/images/
to
domain.com/app/images/{the requested image}
It is my first post in stackoverflow, usually I find all the answers straight by search, but on this I don’t know how to do it.
Btw, I know I could simply do a replace_all on all my views with the fixed path, but as it might change in the future, this would be a much more elegant way.
You can try:
You might want to decide on how you want the urls to permanently be though and just change the redirects to match and just change the rest in the background. You might want to consider Alias as well:
… where {currentpath} has to be filled in
or AliasMatch
and then change the last part when the folder changes, you can also permanently redirect through mod_alias although it’s a little different:
There is also a RedirectMatch as well.
See: http://httpd.apache.org/docs/2.0/mod/mod_alias.html