Grrrr – Site Organization
Posted February 22nd, 2003 @ 11:03pm by Erik J. Barzeski
I was looking over my blog directory on my server and I realized that I've got about 400 files in one directory (the "archives" directory). Why? Every article goes there. Every category, every daily and monthly archive. Every .xml file for the TrackBack system. I have 282 entries and 396 files in there (prior to this one).
I desperately want to move everything to a /2003/02/22/title.php format to reduce clutter (MT can do this I believe). At this rate, I'll have a folder with a few thousand items in it in a few months. That's ridiculous.
Unfortunately, I don't know what the etiquette is. People have links to my articles. Even I have links to my articles. "PermaLinks" are not very permanent. I don't want to ruin the links other people have coded up, but I have to do something.
What should I do? Please let me know.
Posted 22 Feb 2003 at 11:29pm #
Would HTTP status codes be of any assistance in a situation like this? I am thinking specificly of 301 or 302 (Moved Permenantly and Found, respectivley).
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Posted 22 Feb 2003 at 11:34pm #
Huh? The point being that I want the directory emptied. I'm not sure how I can create 301s or 302s to redirect people to the new page.
My backup plan is to email everyone who has a trackback - or post a comment on their site - with the new URL. I only have 54 TrackBacks at this point. I dunno.
Posted 23 Feb 2003 at 12:05am #
what you COULD do is for your archives directory set up a set of 404 error pages which based on the url direct the person to the new page. this can be done with something as simple as reading and parsing the html page produced by mt for the date (you have to know the date first for this), asking the sql database for the date of the entry (far easier) and bulding a new url out of that. What would also be good, would be to inform the authors of said trackback to the location of the new page, so that they can update their links and "trackbacks" and then you can delete the old track back.
Also, when you do this, let me know, i'd like to set this up as well. 🙂
Posted 23 Feb 2003 at 12:24am #
Move your files. Use mod_rewrite to redirect people from the old links to the new locations.
Posted 23 Feb 2003 at 12:24am #
If you don't mind keeping a bit of clutter around, you could just implement the new archiving and hold on to the old files for a little while (they will still exist even after MT reorganizes everything).
Here is information on how to reorganize your files with MT:
http://www.movabletype.org/docs/mtmanual_weblog_config.html#archiving
Posted 23 Feb 2003 at 12:35am #
I don't know how to do mod_rewrite or whatnot. I've made the change and I'm just going to email everyone who's sent me a TrackBack ping. I'm going to update this article in a little bit too to alert people to this. I'm not even sure what the old articles linked to - they're gone now.
/archives/ still has a bunch of .xml files that seem to be used for trackbacks. I'm not sure why MT keeps them there, or how or if I can get them to move into the directories. More work to do.
Posted 23 Feb 2003 at 10:37am #
Why not just drop a .htaccess file in your old archives folder? For each file moved, have:
Redirect oldfileX.html newfullpath/newfileX.html
(one line per file.) Sure it's a pain to write and it'll take ages to write the file, especially with 400 entries, but you'll only need to do it once... there's probably more elegant solutions than that but that's the simplest way...
The other thing to ask is why exactly do you need to make the change? Does it really increase the speed of serving the pages?
Posted 23 Feb 2003 at 10:43am #
Erik's Reorg
My suggestion is: drop that funny 404 message you have now, and put a PHP script in its place... in the script, set up an array associating the number in the /archives/000xxx.php with your new URL. This may be a hassle, but you only have to do it once ...
Posted 23 Feb 2003 at 10:44am #
Ollie: too much work. A 282 line .htaccess file? The fact that I'd have to figure out which article 000182.php linked to? That's hours of work.
I am going to, soon as I'm done with some bug submitting, set my 404 to redirect people to the home page. Maybe.
As to why I made the change: because I routinely SSH in to my box, and because titles are better than #s for files, and because I like to be organized and not "throw everything into one folder."
Posted 24 Feb 2003 at 5:31pm #
What about a 404 page in PHP to grab what they were looking for and redirect to new page? This would rely heavily on regexp's.
Something like this:
$url_request = $REQUEST_URI;
if ( ereg("archives/([^/]*$)",$url_request,$regs) ) {
//$regs[1] now holds what you want
// you could do something like
$newurl = .... some magic here ....
header("Location: http://nslog.com/archives/$newurl");
exit;
} else {
echo "Sorry we didn't that page doesn't exist.. But here's our homepage..."
}
Posted 24 Feb 2003 at 5:37pm #
Yeah, but you left out part. The "some magic here" bit. 🙂
I'm just going to let it go. Most people who have linked to me have updated their links. I'll just let it go. Any further work would be time wasted, I think. Thanks, though.
Posted 13 Mar 2003 at 4:31pm #
This is the guide that I wish I had when I first started out. It would have helped me to avoid certain situations. I've started...
Posted 14 Mar 2003 at 1:58am #
Starting a Blog With Movable Type
Erik Barzeski: This is the guide that I wish I had when I first started out. It would have helped me to avoid certain situations. I've started a few friends in on blogging lately as well, and so this article could have served them too. Perhaps it'll he...
Posted 17 Mar 2003 at 10:50am #
restructuring default archives
If you are new to blogging then starting a blog - with movabletype may be a worthwhile read. I looks...
Posted 26 Mar 2003 at 10:01am #
Archives redesign
Inspired by Erik Barzeski, I've decided to re-design by archives. Before, it was archive/0000000.html or some such, and this created
Posted 02 Apr 2003 at 9:58am #
Take a look at my solution using .htaccess and mod_redirect.
Posted 02 Apr 2003 at 6:54pm #
Site Reorganization
Following Erik's lead, and with the help of Nathan, I have reorganized my individual archive. This change should be totally transparent, but now instead of toomuchsexy.org/archives/000941.php, you will see toomuchsexy.org/archives/2003/04/02/sophies_wo...
Posted 04 Jun 2003 at 6:29am #
pantek
Posted 30 Mar 2004 at 1:27pm #
restructuring default archives
If you are new to blogging then starting a blog - with movabletype may be a worthwhile read. I looks...