Reputation: 189
I've coded my website locally on the root of the server (WAMP running Apache 2.4.2) and i was setting the source for images and other resources with that in mind, so for instance an image called example.png would have "src=/img/example.png". Now i've moved the project to a subfolder, and the images won't load because their link is broken. I do not want to have to set the new source for each image on the html so i was hoping there would be another way to fix the links using mod_rewrite.
To demonstrate: I want a request for
http://localhost/img/logo.gif
to go to
http://localhost/newdir/img/logo.gif
Thanks in advance!
Upvotes: 1
Views: 813
Reputation: 2821
This should do:
RewriteEngine on
RewriteRule !^newdir/ newdir%{REQUEST_URI}
See this post for more info regarding your problem:
https://stackoverflow.com/a/1612329/971459
Carefull to uncomment the following line in your httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
Having the following file structure:
-www
-newfolder
-img
-header.png
-.htaccess
When I access:
localhost/img/header.png I see the image
Upvotes: 2