Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a mature website I only need to generate a thumbnail once, using timthumb, which places the thumbnail in /thumbs/.

try_files $uri ^thumbs/(.*)$ /thumb.php?w=290&q=90&src=../full/%1 last;

How could I fix this code?

Working apache code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/thumbs/(.*)$
RewriteRule ^(.*)$  /thumb.php?h=90&q=90&src=../full/%1 [NS,L]

Thanks in advance :)

share|improve this question
up vote 0 down vote accepted

I think you need to change %1 to $1 in the try_files directive.

share|improve this answer
Hm, I now have this. But het just says the configuration file test failed. – cobra91 Mar 27 '12 at 14:28
Right, the try_files directive can't actually do rewrites. I think you'd have to use try_files $uri /thumb.php?src=$uri;, and either modify thumb.php to accept an entire URL as the source, or add a rewrite directive under a location block for /thumb.php. – mgorven Mar 27 '12 at 18:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.