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

bleggee
bleggee used Ask the Experts™
on
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!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004
Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial