4

I would like to create a friendly url for a specific file from a directory that has a long file path as well as renaming the file. I am not even sure if this is possible.

So far I have tried in htaccess:

RewriteEngine On 
Options +FollowSymLinks
RewriteRule eventdays-2012/brochure.pdf(.+)$ sites/default/files/docs/fact_sheet-204499207.pdf

... but this is not working.

I've done some searching and see where you can mask an entire directory in the file path but in my case I just want to do one file within the directory, create a directory name and change the file name as well.

Danny Englander
  • 2,005
  • 5
  • 26
  • 41

1 Answers1

5

Try removing the (.+) part from your regular expression. It makes it so you need something after the brochure.pdf. Also add some boundaries:

RewriteEngine On 
Options +FollowSymLinks
RewriteRule ^/?eventdays-2012/brochure.pdf$ /sites/default/files/docs/fact_sheet-204499207.pdf [L]
donohoe
  • 13,867
  • 4
  • 37
  • 59
Jon Lin
  • 142,182
  • 29
  • 220
  • 220