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

I have pictures on a path looking like this:


The URL to access it looks like this:


I'd like it to look like this:


Or something similar. The goal is to have the keywords in the URL for SEO.

But would like to tell nginx to serve


When he sees:


I don't want it to redirect the user to the proper URL, I just want it to do the mapping internally.

Is it possible ? How can I achieve this ?

I've seen something similar here, but I can't find a way to apply it to my case. Something noob friendly would be much appreciated.

share|improve this question
up vote 4 down vote accepted

Assuming you've got a base path that's regexable, you can do something like:

location ~ ^/static/(././././.....)/[^/]+/(.*)$ {
    alias /location/on/filesystem/$1/$2;

Nginx's alias directive is more flexible than Apache's equivalent.

share|improve this answer
There is typo. Exclamation mark "!" in location statement should be replaced with tilda "~". – AlexD Jul 18 '11 at 10:47
Thanks for that. You can edit directly though, rather than dropping in a comment. – womble Jul 18 '11 at 10:48
I can't. It prevents me from doing edits wich less than 6 characters long and I don't want to mess with other parts to overcome this limit. – AlexD Jul 18 '11 at 10:50
How odd... I never realised there was a "minimum edit limit". Oh well, thanks for letting me know anyway. – womble Jul 18 '11 at 10:59
Cool thanks. Can you show me how to do that with lighttpd too ? I changed the title. – e-satis Jul 18 '11 at 11:37

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.