Redirect for specific path links I have to make redirect for links:
http://example.com/file/file1.pdf
http://example.com/file/file2.pdf
...
to links:
http://example.com/sites/default/files/file1.pdf
http://example.com/sites/default/files/file2.pdf
...
I've tried .htaccess changing, but fail. (it's too Voodoo for me)
Redirect project has no such function (afaik).
I don't know what hook can I use in my module for such redirect.

How can I make such redirect?

UPDATE:

I've created simple .htaccess file:

  RewriteEngine on
  RewriteRule ^file/(.*)$ sites/default/files/$1 [L]


And it works.

But when I insert in original Drupal .htaccess
line RewriteRule ^file/(.*)$ sites/default/files/$1 [L] after RewriteEngine on
- there is no successful redirect.

Why?

SOLUTION:

  RewriteEngine on
  RewriteRule ^file/(.*)$ sites/default/files/$1 [L, R=301]
As you seem to have learned the Redirect module is really for page-specific redirects (this single URL redirects to that URL), not patterns, as your case seems to require. For this a server-side redirect is really the way to go. Not only is it a standard solution to this kind of problem, but it can happen independent of Drupal, so there is no need to bootstrap Drupal just to process the redirect.

I think the specifics of setting-up a server-side redirect a a bit are a bit beyond the scope of this space (as it's not a Drupal-specific concept), but there are lots of resources out there on the topic, and I think you'll find that it's not too hard. You mentioned that it feels like "Voodo", but I think it will prove far more straightforward than a module-based solution implemented in php. Here's one example stackexchange post that might be relevant to your case.

All that said, because your question does ask for a moudle-specific way to do it, here are some notes on that too. This is much less ideal, as noted above, but it's worth referencing. For this I think you would want to trigger a drupal_goto() inside of hook_init(). A very simple-case example of this pattern can be referenced in this post, and interpolated for your example:

/**
 * Implements hook_init().
 */
function mymodule_init() {
  $path = current_path();
  // preg_match() could also work instead of drupal_match_path()
  if (drupal_match_path($path, 'file/*')) {
    drupal_goto('sites/default/' . $path);
  }
}


I suppose there may be real use cases for this kind of module-based approach, but as I noted above, I really don't think your case is one of them. You would probably be best-served with a service-side redirect (in Apache/.htaccess).