otherground — 2013-06-11T11:44:05-04:00 — #1
I'm trying to use Apache mod_alias / mod_rewrite / scriptaliasmatch to solve the following problem:
I need requests for files in this format:
to be mapped to files that exist at this location:
The first two letters of the file name need to be added to the directory path of the file.
I need this to work for all requests to the images folder, so these URL's
Need to be mapped to the files:
What is the best way to accomplish this?
jeff_mott — 2013-06-11T12:00:09-04:00 — #2
You can capture parts of the original string with (parentheses), then you can use those captured values in the replacement with $1, $2, etc. Here's an example that will probably work. I haven't tested it.
RedirectMatch 301 ^/images/(([^/])([^/])[^/]*)$ /images/$2/$3/$1
otherground — 2013-06-11T12:28:43-04:00 — #3
Thanks so much Jeff .. This worked perfectly once I removed the first forward slash!