Reply to comment

Clients often ask for clean urls in file names because they want to publish them in magazines so they want urls as clean as possible. H

Here is how to do this using mod_rewrite rules in htaccess:

In your .htaccess file of your drupal root folder you add following line.
For example :
All http://yourdrupal/pdf/whatever.whatever will be redirected to http://yourdrupal/sites/yourdrupal/files/private/whatever.whatever

  RewriteRule ^pdf/(.*)$ /sites/yourdrupal/files/private/$1 [L,QSA]

For more info on apache mod_rewrite rewrite rules: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule and http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

EDIT:
To output logging you should put this in your virtual host directive:

RewriteLog /rewrite.log
RewriteLogLevel 9

This will give you a clear view on how apache is rewriting.

EDIT2:
To not interfere with drupal rewriting you should put an extra condition in the drupal rewriting. (Taken from .htaccess)

For example

  RewriteCond %{REQUEST_URI} ^/DATASERVICE/WIKI/(.*)$
  RewriteRule ^(.*)$ /sites/default/files/$1 [L]
  #the [L] will tell apache to stop executing other rewrite rules
 
  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

EDIT3:
More examples:
http://www.workingwith.me.uk/articles/scripting/mod_rewrite

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><img><p><b><i><table><th><tr><td><blockquote><br /><img /><tbody><span><strike>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <codes>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.