I’ve come up with a simple solution for handling user uploaded content when trying to work in a local development environment. I’ve installed XAMPP on my windows machine and at the beginning of every week I take a database snapshot and update my local database. I had a pretty smooth system going with one problem: user uploaded content.
When working with social networking sites, many times they allow for users to upload their own videos, pictures, etc. My current project wasn’t different, but I didn’t want to download 80GB of user content every week to store on my PC. I wanted a way to point my browser to the live server to get recent images, etc.
My solution was simple: .htaccess file using a 301 redirect. I basically told my local apache server to return a HTTP status of 301 (Moved Permanently) and point the browser to the live content. I created a .htaccess file inside the “uploads” directory and added one line of code:
Redirect 301 /uploads http://www.example.com/uploads
I restarted apache and now when I work locally, I can still see all of the user’s photos and uploaded content. Works like a champ!