I have an image sharing website and I used to have a sub-domain for the images, however I had to delete it, so now I use a real path to the images:
old url:
http://img.site.com/images/2013/03/abc.jpg
new url:
http://site.com/files/images/2013/03/abc.jpg
The problem with this is that I have a lot of images linked from other websites and search engines that are still using the old URL.
The problem with the old sub-domain is that it's directory (public_html/files
) and its name (img.
) are different, so special configuration was needed to handle that and I got tired of all the problems that it was causing.
Now I have created a normal img.
sub-domain that is pointing to the public_html/img
directory so that no extra configuration needed, however my images are still in the public_html/files
directory.
I figure all I have to do now is replace the new directory with the old one using .htacess somehow. I don't know if this is possible.
My .htaccess
is currently:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^img\.site\.com$ [NC]
RewriteRule ^(images/.*)$ http://site.com/files/images/$1[R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
When I try to call an image from a subdomain I get:
Not Found
The requested URL /files/images/2013/10/15c100d1da3216850d6cceb4ce57eaab6d26fc92.jpg was not found on this server.
img.site.com
My error log reports:
[Mon Oct 21 02:58:46 2013] [error] [client 85.185.229.221] script '/home/site/domains/site.com/public_html/img/index.php' not found or unable to stat