SEO: Is a redirect without using 301 but a PHP script, OK?

I’ve been reading about redirection, and how it can affect (or not if done properly) SEO.

I’m changing my website’s content platform from Drupal to a PHP custom made code.

In my current site I have two links that point to the same link like this:

…/node/123

…/my-node-title

Mainly because Drupal allows you to create a custom-made links, so every article has a default one (node/123) and the custom-made one (/my-node-title).

My question is about what to do in order to prevent losing any SEO that each link may have.

In the new website all articles are structured like this: content.php?id=123

I’ve stored in the database the custom-made link of every article.

Instead of doing a 301 redirect I’m rewriting all links that do not exist to be redirected to redirect.php page to process the request. There I take the string from the link, look for it in the database and redirect the user.

The process is like this:

in .htaccess file:

RewriteRule ^.*$   ./redirect.php 

In redirect.php:

I grab the $ _SERVER['REQUEST_URI'] and using explode() I get the last part of the link (ie. my-node-title), look for it in the database and grab the ID of the article (ie. 123) and save it in a $ link variable.

Then I use header() function and do the redirect: header('Location: '.$ link);

So, people still click on .../my-node-title but when the article loads at the navigation bar appears /content.php?id=123

I would like to know your comments about this solution. I know that with SEO there are not fixed rules, or certainty in anything, but I would like to know if what am I doing is acceptable. Thanks!