What's the best way to customize / make the URL of uploaded files to look "clean" (e.g. /files/my-doc.pdf instead of /system/files?file=my-doc.pdf) without compromising security by using the "Public - files are available using http directly" -method for file transfer?

I'm an experienced PHP programmer and have already done quite a bit of Drupal hacking, so low level implementation ideas are also welcome if there's no other, simpler way.

Comments

videojunky’s picture

if u lookup some details on mod rewrite i'm pretty sure u can specify a certain folder for it to rewrite to the shorter address.
http://httpd.apache.org/docs/mod/mod_rewrite.html

elonen’s picture

Yes, that would work for incoming requests, but the problem is that the outgoing pages would still have the same, cumbersome URIs.

Steven’s picture

First, you need to get rid of the ?q=. Make sure the Drupal .htaccess file is being used, and that clean URLs are turned on in admin > settings.

Then you can create an URL for any of your files through the admin > url aliases page (requires path.module).

--
If you have a problem, please search before posting a question.

elonen’s picture

Could you give an example? I know url aliases, but do they also work on attachments in addition to the nodes themselves?

If so, how should I write the "original" address when adding the alias? Trying files?file=myfile.pdf gives an error message "The system path files?file=myfile.pdf is invalid".