Coding of .htaccess for canonical issue & robots.txt for sitemap

Can someone check this please ... Is this the correct coding for robots.txt if I put a sitemap.xml file in the web root folder:
     User-agent: *
     https://EXAMPLE.COM/sitemap.xml
and
Is this the correct coding for .htaccess if I want to direct all requests to the Non-www https version of a URL:
     RewriteEngine On
     RewriteCond %{HTTP_HOST} ^www\.EXAMPLE\.com [NC]
     RewriteRule ^(.*)$ https://EXAMPLE.com/$1 [L,R=301]
     RewriteCond %{SERVER_PORT} 80
     RewriteRule ^(.*)$ https://EXAMPLE.com/$1 [L,R=301]
Any advice appreciated!
LVL 1
bleggeeAsked:
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.

Steve BinkCommented:
Regarding canonical hostnames, Apache's guidance is available at https://httpd.apache.org/docs/2.4/rewrite/remapping.html#canonicalhost and https://wiki.apache.org/httpd/CanonicalHostNames.  While they recommend using multiple VirtualHost containers alongside a Redirect directive, I typically prefer the rewrite method.

Regarding SSL enforcement, the wiki again provides some guidance: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS and https://wiki.apache.org/httpd/RedirectSSL.  In this case, I prefer the Redirect approach, since I typically enforce SSL across the entire site.  Without having to parse individual request names, a host-wide Redirect does the job.

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
Search Engine Optimization (SEO)

From novice to tech pro — start learning today.