caching - How to do .htaccess redirect and HTTP cache for static images in a no-cookie subdomain -


we want redirects our site photos domain.com/images/ no-cookie img.domain.com. currently, have images directory in public_html, urls are:

http://domain.com/images/subfolder-1/title-of-the-image.jpg http://domain.com/images/subfolder-2/title-of-the-image.jpeg http://domain.com/images/subfolder-3/title-of-the-image.gif http://domain.com/images/subfolder-4/title-of-the-image.png 

in cpanel, img.domain.com has been set publi_html/images

we tried unset cookie , redirect via htaccss. yet, not work.

in htaccess,

adddefaultcharset utf-8  ## re-directing options +followsymlinks -multiviews rewriteengine on rewritecond %{http_host} !^(www\.)?images\. [nc] rewriterule ^(.*)$ http://www.img.domain.com/$1 [l,ne,r=301]  # expire headers <ifmodule mod_expires.c>     expiresactive on     expiresdefault "access plus 29030400 seconds"     expiresbytype image/x-icon "access plus 29030400 seconds"     expiresbytype image/jpeg "access plus 29030400 seconds"     expiresbytype image/jpg "access plus 29030400 seconds"     expiresbytype image/png "access plus 29030400 seconds"     expiresbytype image/gif "access plus 29030400 seconds" </ifmodule>  # headers <ifmodule mod_headers.c>     <filesmatch "\\.(ico|jpe?g|png|gif|swf)$">         header unset cookie         header unset set-cookie         header set cache-control "max-age=29030400, public"         header set last-modified "mon, 24 mar 2014 00:00:00 gmt"     </filesmatch> </ifmodule> 

we wonder keep/add/change in above .htaccess code, located inside images directory, or if there better ways. thanks!

add rule below rewriteengine on in /images/.htaccess file:

rewritecond %{http_host} !^(www\.)?images\. [nc] rewriterule ^(.*)$ http://www.images.domain.com/$1 [l,ne,r=301] 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -