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!
Related Posts
- PHP Design - Biggest Database Oversights Over the last three years I've had the opportunity to work on several PHP projects, some of them having grown rapidly and required to scale quickly. Three in particular have been a fantastic learning experience for me. Now I don't consider myself a total expert, but I thought I would...
- PHP Singletons, Sub-Classing, and HAS-A Relationships I've been very busy these last fews weeks and have neglected making any posts. While there are a variety of subjects I'd love to post about, they'll most likely have to wait until the next year. However, I thought I might be able to throw up a quick example of...
- OS X and Tabs - Skipping Drop Down Controls Comcast is supposed to come tomorrow to hook up my house, but until then I've been mooching of relatives' WI-FI on my Mac Book Pro. ... Of course the OS X elite call this change simple and easy, but I'd think it'd be easy to just have it work in...
- ASP .NET & System.Threading.ThreadAbortException Error While doing some work today I started to run into a ThreadAbortException error. While debugging it spit back this error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. I was really confused because everything seemed to be...
- MS SQL 2005 (T-SQL) Row Count for Each Table At work I needed a solution to give me a count of how many rows each table contained. I've always liked phpMyAdmin's ability to list all the tables and show their size and row count. I've found it immensely helpful. However, I couldn't find anything similar for SQL Server Manager...

Recent Comments