: How should I properly redirect 1 million+ URLs? I have a server that allows file uploads. Foolishly I let everything get stored in one directory /uploads. Now that I am approaching 1.5M files
I have a server that allows file uploads. Foolishly I let everything get stored in one directory /uploads. Now that I am approaching 1.5M files in this directory, I want to go back and correct my mistake. I am going to move all files into date based directories like so /uploads/2/14/file.ext. How can I do this without ruining all links that currently exist to the files? If someone tries to access site.com/uploads/file.ext it needs to show them the content from site.com/uploads/2/14/file.ext. How do sites like Imgur make it seem as if all their files are stored in one directory?
Things I have thought of:
.htaccess redirect (I think this would be way too many URLs to store in this type of file).
MySQL based redirect (I think this would cause way too much load on the DB as there are millions of files viewed each day.
More posts by @Goswami781
1 Comments
Sorted by latest first Latest Oldest Best
I would advise to keep a MySQL table that saves the mapping of the file id, to the directory it is kept in. You shouldn't be worried about the DB load considering 1.5M rows and millions of queries per day. For such a simple 1:1 link query. Just make sure you add the proper index to the key you search according to, and if you wish to be better prepared for scale, keep the key an number.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.