Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've migrated my blog from DotClear2 to WP3.

I would like to add some URL rewriting on my NGinx configuration file, so that people who were following my blog using the RSS can still do the same without having to change the address in their aggregator.

The previous URL was: while the new one is:

How could I write a rewrite rule in NGINX so that it automatically transfers to the new URL?

In short, I'd like to get rid of the /blog/ word in the URL.


share|improve this question
You should probably also remove that extra /index.php from your URLs. – Michael Hampton Aug 24 '12 at 18:31

2 Answers 2

up vote 0 down vote accepted

After some unsuccessful tries, this one seems to be working well

server {
    listen 80;
    root /var/www/http/emidee;

    include global.conf.d/restrictions.conf;
    include global.conf.d/wordpress.conf;

    rewrite ^/blog(.*)$ $scheme://$server_name$1 last;
share|improve this answer

That should do the trick:

server {
  # more code ...
  location / {
    # more code ...
    location ~* ^/blog/([a-z0-9\.]+)$ {
      return 301 $scheme://$server_name$1;
    # more code ...
share|improve this answer
Thank you for your answer, but unfortunately I'm not redirected to when I access Is there a way to debug what's going on under the hood? – Mike Aug 24 '12 at 21:53
You can always activate debug logging, then nginx logs exactly what it's doing. But the rewrite rule you posted seems just fine. :) – Fleshgrinder Aug 25 '12 at 4:48

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.