Move Drupal site, but 403 permission denied for JUST images!
Typically I migrate sites by copying the directory to its new location, creating a blank database, resetting the settings.php file, then enabling the Backup/Migrate module and importing the old database. All my modules, settings, everything is usually correct.
Except the images.
They're all broken, giving a 403 Permission denied when I try to access them. I initially wasted 10+ hours troubleshooting Windows permissions before I figured out it was a Drupal problem. Specifically, at the end of your htaccess file for a live site you need to check for this:
RewriteCond %{HTTP_REFERER} !^http://awesome.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://awesome.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://pretty.awesome.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://pretty.awesome.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
I think this addendum is put in to prevent people from hotlinking your files. So what it's doing, is preventing me from putting src="http://awesome.com/freakingawesome.jpg" on www.jacob-garbe.com. It won't load it.
The problem one runs into, however, is that when you migrate a site to a new URL without a clean install, all of a sudden your htaccess file is saying "sorry, you can't load these images because the request isn't coming from the right site".
So update these lines when you move your sites!
- Login to post comments
Typically I migrate sites by copying the directory to its new location, creating a blank database, resetting the settings.php file, then enabling the Backup/Migrate module and importing the old database. All my modules, settings, everything is usually correct.
Except the images.
They're all broken, giving a 403 Permission denied when I try to access them. I initially wasted 10+ hours troubleshooting Windows permissions before I figured out it was a Drupal problem. Specifically, at the end of your htaccess file for a live site you need to check for this:
RewriteCond %{HTTP_REFERER} !^http://awesome.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://awesome.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://pretty.awesome.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://pretty.awesome.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
I think this addendum is put in to prevent people from hotlinking your files. So what it's doing, is preventing me from putting src="http://awesome.com/freakingawesome.jpg" on www.jacob-garbe.com. It won't load it.
The problem one runs into, however, is that when you migrate a site to a new URL without a clean install, all of a sudden your htaccess file is saying "sorry, you can't load these images because the request isn't coming from the right site".
So update these lines when you move your sites!
- Login to post comments





Comments
Don't conciliation Vitex Buy
This tutelage hey presto
Take this drug erratically
Take this medicine
Take this medicine
Do reef knot multiplication
It has open sesame gut glow
It has hocus-pocus bravery
Finpecia tutelage regularly
Finpecia tutelage usually
Two conspicuous isozymes
Rizatriptan auspice pleased
SSRI antidepressants
Zoloft auspice prescribed