htaccess 301 redirect of website, excepting certain pages

I'd like to perform a 301 redirect of www.mauitradewinds.com to mauitradewinds.com in order to eliminate the search rank issue of duplicate content.  But there are a few pages in my domain which require the www prefix in order to retain their function.  

In order to have a model for the redirection which I would like to implement, can you suggest .htaccess code which redirects the entire site, except for www.mauitradewinds.com/page1.htm and www.mauitradewinds.com/page2.htm?
LVL 1
ddantesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DamjanCommented:
Try with

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/page1.htm$
RewriteCond %{REQUEST_URI} !^/page2.htm$
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ddantesAuthor Commented:
Thank you.  May I ask one more favor?  Could you provide code for redirecting the other way, from non-www to www, except for those two pages?
0
DamjanCommented:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/page1.htm$
RewriteCond %{REQUEST_URI} !^/page2.htm$
RewriteCond %{HTTP_HOST} ^mauitradewinds.com
RewriteRule (.*) http://www.mauitradewinds.com/$1 [R=301,L]
0
ddantesAuthor Commented:
Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.