Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

So I've been playing with rewrite for awhile, and I can't get it.

Basically, when a user visits http://mydomain.com/images/username.png I want it to actually display the results of http://mydomain.com/stats.php?user=username

This was what I had before I finally gave up:

rewrite "/images/([a-zA-Z0-9_-]+).png" /home/wwwroot/stats.php?user=$1;

Can anyone tell me what I'm doing wrong?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Don't use the file path for your replacement. Try this:

rewrite ^/images/([-\w]+)\.png$ /stats.php?user=$1;

And you'll want to make sure that your PHP code is setting the right MIME type on the response.

share|improve this answer
    
That absolutely did the trick. Thank you so much! –  Rob Jan 16 '12 at 7:27

Your Answer

 
discard

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.