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

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'm trying to redirect$ to$. How do I edit this to strip the /blog from the redirect?

location /blog {
    rewrite ^/(.*)$1 break;

It now redirects to (so blog is still there).. Thanks in advance!!

share|improve this question
You may try: rewrite ^/blog/(.*)$1 break; (in which case, you might also be able to get rid of the location block). – cyberx86 Jun 10 '12 at 22:57
It works!!! :) Thanks!! I can't set your reply as the right one because you added a comment instead of a reply (I think.. I'm rather new here).. :( – MultiformeIngegno Jun 10 '12 at 23:16
You cannot accept a comment - and respondents shouldn't post answers as comments - it's a bad habit of mine (usually when I don't have a chance to verify my answer). Posted as an answer so you can close out the question. – cyberx86 Jun 11 '12 at 0:21
up vote 2 down vote accepted

You want the regex part of your rewrite to match against ^/blog/ and capture everything following it:

rewrite ^/blog/(.*)$1 break;

Using such an approach, you may also be able to get rid of the location block.

share|improve this answer

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.