Results 1 to 3 of 3
Jun 11, 2013, 08:44 #1
mod_rewrite: rewrite URLs using sub-string of file names for directory paths?
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?
Jun 11, 2013, 09: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"First make it work. Then make it better."
Jun 11, 2013, 09:28 #3