We want to do redirects for our site photos from domain.com/images/
to a no-cookie img.domain.com
.
Currently, we 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 to publi_html/images
We tried to unset cookie and redirect via htaccss. Yet, it does 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 what to keep/add/change in the above .htaccess code, which is located inside images
directory, or if there are better ways. Thanks!