I'm trying to use Stacey CMS in conjunction with retina.js for my small portfolio site. Stacey tells all images inside a project folder to be added to the page. At the same time I'd like to serve @2x
hi-dpi images. If I include these in the same folder, Stacey will add both the regular image.png
and image@2x.png
to the page, which I want to avoid.
To solve this, I want to rewrite all images ending with @2x
to have the root /retina
inside the same project folder. This folder is dynamic, ie. there are many different project folders, so I would like to have one rewrite rule to work for all.
I've gotten to this point with some help from a fellow stack overflow user:
RewriteRule ^(.*)@2x(.*)$ /Retina/$1@2x$2 [L]
This however, does not refer to a subfolder of the original project folder. How do I go about referring to the correct folder?
Edit: Alternatively there may be other ways to solve this issue? Changing retina.js retina image path
I think that the problem you encounter is do to an endless redirect loop. as your rule
Will try to redirect the call for the retina image uri like /image@2x.jpg but also again and again for the new url's /retina/image@2x.jpg as your rule only checks if the requested uri has the
@2x
string in it.Try adding another condition to the rule that will prevent the rule to be processed for images that are in the
retina
folderIf the
Retina
folder is actually inside another folder and you have multipleRetina
folders, meaning that when you callsite.com/project1/image.png
the retina version is insite.com/project1/retina/image@2x.png
then you should try this:in the
Retina
folders are inside the sub-folders, the first rewrite rule we used will have both the folder name & the image name in the variable $1, so what we should do is just break the folder name & the image name into two separate variables