Consider the following directories:
[font=courier]archive/20140420-1500/
archive/20140420-1800/
archive/20140421-1000/[/font]
Yes, this are essentially date-time stamps used as directory names. The contents of the directories are irrelevant to my problem, but they contain HTML files.
Parallel to [font=courier]archive/[/font] is the directory named [font=courier]current/[/font].
What I would like to do is this: whenever someone points their browser to [font=courier]current/index.html[/font] (or just [font=courier]current/[/font] as the index file will be pulled up by default) they would redirect to the most recent directly in [font=courier]archive/[/font].
So in the example above, if I point my browser to [font=courier]current/[/font] I would be redirected to [font=courier]archive/20140421-1000/[/font].
But if I later add a new directory named [font=courier]archive/20140421-1100/[/font] then [font=courier]current/[/font] would redirect me there, without me having to update anything.
I suppose this could be done one of two ways:
- Redirect to most recently created directory
-or- - Redirect to the [font=courier]archive/[/font] subdirectory with the highest name value (since my naming convention puts things in sequence with the most recent date at the bottom of the list.)
The redirect I can handle with a simple HTML [font=courier]meta[/font] redirect. Just having trouble using PHP to scan the archive directory and dynamically generate HTML to point to the most recent archive folder.
If there is an even easier way to go about this, I’m all ears. I have a suspicion this could be done with .htaccess as well, but I’m even less competent in that than I am in PHP.
Really appreciate any help! Many thanks.