I recently moved my blog from using WordPress over to using Jekyll (I like the idea of static files for my blog). I'm using Nginx (was using it with PHP-FPM before) and have things setup to handle stuff. I've encountered one problem I do not know how to fix.

The URL structure I'm using is


I have about 5 years worth of blog posts that have been indexed by Google and they are


I want to rewrite all the older calls with the trailing slash to use the non-trailing slash URL until Google indexes all the new stuff.

Here is the nginx config stuff I have already:

    location /atthekeyboard {
            index index.html;
            try_files $uri.html $uri/ /notfound.html;

I'm using try_files because the posts are actually saved as title-of-post.html and I didn't want the .html part.

Thanks in advance for your advice and solutions!


Something like this should remove the trailing slash and then let Nginx reparse the location blocks.

location ~ ^(/atthekeyboard/.+)/$ {
    set $noslash $1;
    rewrite ^ $noslash permanent;
  • I added that in and I get '[emerg]: unknown "noslash" variable' when I run nginx -t – GrumpyCanuck Feb 28 '11 at 14:38
  • @GrumpyCanuck Edited it, should be compatible with older nginx versions now. – Martin Fjordvald Feb 28 '11 at 21:37
  • sorry, still not working :( Here's a paste of the configuration file I had to add a $ to noslash in the set command in order to get nginx to stop complaining. In case it matters, I'm using nginx version 0.7.67 – GrumpyCanuck Feb 28 '11 at 23:36
  • @GrumpyCanuck it was me being stupid, the configuration actually does work but I had forgotten the permanent flag on rewrite so it did an internal redirect instead of an external one. So while it redirected you couldn't actually see it. – Martin Fjordvald Mar 1 '11 at 7:29

i think the HTTPRewriteModule is what you are looking for

  • Duh, I should've mentioned that I do know about the HTTPRewriteModule but I have been unable to figure out the proper rewrite rule to make it happen. – GrumpyCanuck Feb 28 '11 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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