How do i redirect my customers from example.com / or www.example.com to new.example.com

however i shouldn't redirect some specific web addresses like:

www.example.com/test.php
api.example.com/testo.php
www.example.com/forum/index.php

Used to do:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ http://new.example.com/$1 [R=301,L]

but what's the rules for web addresses?

One method to do that would be to create additional rules earlier within the .htaccess apply for the particular Web addresses that simply redirect privately (internally, not utilizing a 3XX response), after which make use of the L flag so no later rules are processed for individuals Web addresses.

For instance:

RewriteEngine on

# don't redirect these
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(/test.php)$ \1 [L]

RewriteCond %{HTTP_HOST} ^api.example.com$
RewriteRule ^(/testo.php)$ \1 [L]

RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(/forum/index.php)$ \1 [L]

# redirect these
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ http://new.example.com/$1 [R=301,L]

I am unsure in case your "don't redirect" needs incorporated the hostname. Otherwise, then just take away the RewriteCond lines.