lucy24 - 4:00 am on Aug 24, 2013 (gmt 0)
Edit: I was typing while the last few posts were coming in, so scroll back about half an hour.
JD, you may not have noticed that there are two parallel threads on the same question. The other one's next door in php, but the underlying questions are still about constructing Regular Expressions.
RewriteRule ^name/((.)(.?)(.?).*)/$ /cache/$2/$3/$4/$1.html
You can't do this. If the filename is less than four characters, captures 2-4 may be empty and you'll be rewriting to, at worst,
A bit further up this thread I suggested leaving hyphens out of the directory names by setting up everything in the form
((\w)-?(\w)-?(\w)blahblah) >> /$2/$3/$4/$1
This rule comes before the ones made for supershort filenames
But if you can dump the whole thing on your php, you don't need any of this in htaccess. All that's left is
The object is to collect all the Regular Expressions into one place. Depending on how you code, you can either have two different php files that both call the same subfile (which contains the RegExes), or start out in a single php file which then branches out in different directions for creating a new file or retrieving an existing one.
Edit as we overlapped:
Where (/$3)(/$4) only populate on the right side if it matched something on the left?
Not in htaccess, but it can easily be done in php. I think JD lays it out in the post right before mine.