how to do redirect and standardize URL in the same htaccess file

Hi, I am very new to htaccess and need a solution to my problem ASAP. I need to create a htaccess file that does two things for me;

1. it needs to redirect from http to https protocol.
2. it also needs to standardize the URL web address so it always includes 'www' in the URL.

I found some solutions (listed below) that solve each of these situations, but I need one htaccess file that does both and that is where I am having problem. The solutions I've found are as follow:

--------------------------------------------------------------------
// Redirecting from http to https protocol

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
----------------------------------------------------------------------
// standaridise URL so it alwaysinlcude 'www'


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
// ---------------------------------------------------------------------

Again how do I write one htaccess file that covers both situations?

thanks
dmehranAsked:
Who is Participating?
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.

ravenplCommented:
Just put both rewrites to same .htaccess file

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] # L means stop rewriting

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

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
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.