Last night I was reading an article about the worst mistake in software development: a complete rewrite of the companies flagship software.
I can definitely confirm that it is a really bad idea in general to do a complete rewrite: by personal experience because I for myself did that mistake and by second hand experience - I have several friends struggling with the same problem.
On the other hand it can be a very good idea to cut off old code and replace it by new code: have a look at the
libressl. Another example may be the nginx project, which is able to outperform Apache just because the code base is not that crufted.
I can't tell you what the right way for your project is, but I thought it might be a good idea to share that link from above. It is an interesting read either way.