Forum Moderators: coopster & phranque

Message Too Old, No Replies

Yet another mod_rewrite question

Maybe 301 or 302, then 404 if necessary

         

bobriggs

7:38 pm on Apr 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Aaaah, one for the mod_rewrite gurus.

Suppose you have files in example.com/exampledir/

You decide that older files will go into example.com/exampledir/archive/ (maybe monthly)

After a certain period of time (annually), you want to remove them from /exampledir/archive/

files all have extension .html, would never be index.html or anything like that.

If they're in /exampledir - all should be as normal - don't look anywhere else.

If they're in /exampledir/archive/ - you want them displayed, and preferably with a 301 or 302 redirect.

And finally, if not in /archive/ they've been removed. And I'd rather have a 410 result, not a 404.

Is this possible?

DrDoc

7:29 am on Apr 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For /exampledir, have a 404 redirect pointing to a script that will look for the file in /exampledir/archive .. If there, you can have the script return a customized page (a 301 or 302 page), and if not there it can return a 410 page .. So, yes, it is possible ..

But, is that what you wanted to know?

Or, did you want to know if it's possible to move and delete the files automatically??

bobriggs

10:31 am on Apr 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, that's what I wanted to know.

I was looking for a more elegant solution, (one without having to use a script), but your solution does give me some ideas.

Thanks.

bird

12:47 pm on Apr 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't think this is possible without a script. If you set a custom 404 page (which is not done by mod_rewrite, btw.), and that custom page doesn't exist, then apache will simply output a line of text saying so. It can't follow 404s recursively, or it would end up in an infinite loop in most cases.