Q:

.htaccess, skip a variable level

I am struggling with a .htaccess issue.
I have a url like /files/download/1234/abc/def.pdf where /1234/ is a variable value and changes for each user.
However recently we transferred all the files to /userdownload/abc/def.png
How do i skip the variable level using my .htaccess file?
I tried stuff like:
^files/downloads/(.*)/(.*)$ http://www.example.com/userdownload/$2 [R=301,L]

However this did not give the result i needed as it also removed the /abc/ from the link.
Anyone knows how i can fix this issue?

A:

You can use:
RewriteRule ^files/downloads/(\d+)/(.*)$ http://www.example.com/userdownload/$2 [R=301,L]

If your variable is only numeric.
Or you can use:
RewriteRule ^files/downloads/([^/]+)/(.*)$ http://www.example.com/userdownload/$2 [R=301,L]

