So I recently sorted all my files on a subdomain into different folders, let's just call it upload.example.org
. One of the new folders is titled "img" (public_html/upload/img
), where I now automatically upload any pictures I take for easy sharing. Previously all images were in the document root folder "upload" and that's where I used to share the URLs from, so a redirect to the new URL is needed to avoid breaking anything.
Now what I've been trying to do is create a .htaccess that redirects people from upload.example.org/image.jpg
to upload.example.org/img/image.jpg
. image.jpg
can be replaced with any other file name in the img folder.
Looking for answers, I found this:
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Using this line of code with my subdomain results in a loop, in the end redirecting me to http://upload.example.org/img/img/img/img/img/img/img/img/img/img/image.jpg
.
After searching and trying out different .htaccess variants, I couldn't come across the correct solution.
Any help that you can give would be much appreciated! :)