{"id":421,"date":"2021-06-29T07:31:58","date_gmt":"2021-06-29T12:31:58","guid":{"rendered":"https:\/\/www.knownhost.com\/kb\/?p=421"},"modified":"2021-10-12T07:08:32","modified_gmt":"2021-10-12T12:08:32","slug":"htaccess-invalid-command-xefxbbxbf","status":"publish","type":"post","link":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/","title":{"rendered":".htaccess: Invalid command &#8216;\\xef\\xbb\\xbf#&#8217;"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_1 ez-toc-wrap-right counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #212121;color:#212121\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #212121;color:#212121\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#the_dos2unix_command\" >The dos2unix Command<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#a_simple_quick_fix\" >A Simple, Quick Fix<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#preventing_the_issue\" >Preventing the Issue<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>If you receive the following error, you&#8217;ve edited your file with software that has added a BOM magic numbers to the file, which Apache cannot read:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  \/home\/user\/.htaccess: Invalid command '\\xef\\xbb\\xbf#', perhaps misspelled or defined by a module not included in the server configuration<\/code><\/pre>\n\n\n\n<p>&#8216;\\xef\\xbb\\xbf#&#8217; is a &#8216;Unicode BOM(Byte Order Mark)&#8217; and consists of invisible characters added by certain text editors like Notepad++, for instance. The BOM often functions as a magic number used to pass along information to the program reading the file, such as the Unicode character encoding or endianess.<\/p>\n\n\n\n<p>A BOM&#8217;s presence can interfere with software that does not expect it, which is what is happening when Apache attempts to read an .htaccess file that contains a BOM. This causes the <a href=\"https:\/\/www.knownhost.com\/kb\/what-is-error-code-500-on-my-server\/\">500 Internal Server Error<\/a> seen in the browser when you attempt to load a site whose .htaccess inadvertently contains a BOM.<\/p>\n\n\n\n<p>Let&#8217;s see how using the&nbsp;<em>dos2unix -r<\/em>&nbsp;command removes the BOM from a file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"the_dos2unix_command\"><\/span>The dos2unix Command<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let&#8217;s explore this further.<\/p>\n\n\n\n<p>First, let&#8217;s create a file containing a BOM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  ~$ printf \"\\xef\\xbb\\xbf\" &gt; manualBOM.txt\n  ~$ cat manualBOM.txt \n  ~$ ls -lah manualBOM.txt \n  -rw-rw-r-- 1 user user 3 Sep 27 05:20 manualBOM.txt\n  ~$ hexdump manualBOM.txt \n  0000000 bbef 00bf                              \n  0000003\n  ~$<\/code><\/pre>\n\n\n\n<p>After confirming the presence of the BOM by viewing the contents of the file with&nbsp;<em>hexdump<\/em>, we can remove the BOM with the&nbsp;<em>dos2unix<\/em>&nbsp;command accompanied by the&nbsp;<em>-r<\/em>&nbsp;modifier (<em>\u2013remove-bom<\/em>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  ~$ dos2unix -r manualBOM.txt\n  dos2unix: converting file manualBOM.txt to Unix format...\n  ~$<\/code><\/pre>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;that you may need to install this utility using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  yum install dos2unix -y<\/code><\/pre>\n\n\n\n<p>Now, let&#8217;s inspect the file to confirm the BOM has been removed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  ~$ cat manualBOM.txt\n  ~$ ls -lah manualBOM.txt\n  -rw-rw-r-- 1 user user 0 Sep 27 05:21 manualBOM.txt\n  ~$ hexdump manualBOM.txt\n  ~$ <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"a_simple_quick_fix\"><\/span>A Simple, Quick Fix<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Perhaps the quickest way to fix the issue would be via SSH. One would need to change into the document root of the site, rename the .htaccess file to .htaccess.bak, then cat the contents of the .htaccess.bak file to a new .htaccess file, and then ensure the correct ownership of the .htaccess file. Assuming the document root for the site is&nbsp;<em>\/home\/user\/public_html&nbsp;<\/em>, and the username is&nbsp;<em>user<\/em>, the commands would be as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  cd \/home\/user\/public_html\/\n  mv .htaccess .htaccess.bak\n  cat .htaccess.bak &gt; .htaccess\n  chown user.user .htaccess<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"preventing_the_issue\"><\/span>Preventing the Issue<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To prevent this issue, always use a Linux-compatible text editor (vim, nano, etc.,) or configure your text editor to save files without a BOM. This can be done in Notepad++ via the top bar menu:&nbsp;<em><a href=\"https:\/\/community.notepad-plus-plus.org\/topic\/7409\/utf-8-without-bom-option\">Encoding &gt; Encode <\/a><a href=\"https:\/\/community.notepad-plus-plus.org\/topic\/7409\/utf-8-without-bom-option\" target=\"_blank\" rel=\"noreferrer noopener\">in UTF-8&nbsp;<\/a><\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you receive the following error, you&#8217;ve edited your file with software that has added a BOM magic numbers to the file, which Apache cannot read: &#8216;\\xef\\xbb\\xbf#&#8217; is a &#8216;Unicode BOM(Byte Order Mark)&#8217; and consists of invisible characters added by certain text editors like Notepad++, for instance. The BOM often functions as a magic number [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[94],"tags":[177,109,143,128,238,123,145,144,125],"class_list":["post-421","post","type-post","status-publish","format-standard","hentry","category-common-issues","tag-cloud","tag-cpanel","tag-dedicated","tag-directadmin","tag-htaccess","tag-linux","tag-reseller","tag-shared","tag-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>.htaccess: Invalid command &#039;\\xef\\xbb\\xbf#&#039; - KnownHost<\/title>\n<meta name=\"description\" content=\"Learn how to solve .htaccess: Invalid command &#039;xefxbbxbf#&#039; and ways to prevent that from happening in the future.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\".htaccess: Invalid command &#039;\\xef\\xbb\\xbf#&#039; - KnownHost\" \/>\n<meta property=\"og:description\" content=\"Learn how to solve .htaccess: Invalid command &#039;xefxbbxbf#&#039; and ways to prevent that from happening in the future.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\" \/>\n<meta property=\"og:site_name\" content=\"KnownHost\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-29T12:31:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-10-12T12:08:32+00:00\" \/>\n<meta name=\"author\" content=\"Jonathan K. W.\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan K. W.\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\"},\"author\":{\"name\":\"Jonathan K. W.\",\"@id\":\"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b\"},\"headline\":\".htaccess: Invalid command &#8216;\\\\xef\\\\xbb\\\\xbf#&#8217;\",\"datePublished\":\"2021-06-29T12:31:58+00:00\",\"dateModified\":\"2021-10-12T12:08:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\"},\"wordCount\":366,\"keywords\":[\"cloud\",\"cpanel\",\"dedicated\",\"directadmin\",\"htaccess\",\"linux\",\"reseller\",\"shared\",\"vps\"],\"articleSection\":[\"Common Issues\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\",\"url\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\",\"name\":\".htaccess: Invalid command '\\\\xef\\\\xbb\\\\xbf#' - KnownHost\",\"isPartOf\":{\"@id\":\"https:\/\/www.knownhost.com\/kb\/#website\"},\"datePublished\":\"2021-06-29T12:31:58+00:00\",\"dateModified\":\"2021-10-12T12:08:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b\"},\"description\":\"Learn how to solve .htaccess: Invalid command '\\\\xef\\\\xbb\\\\xbf#' and ways to prevent that from happening in the future.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.knownhost.com\/kb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\".htaccess: Invalid command &#8216;\\\\xef\\\\xbb\\\\xbf#&#8217;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.knownhost.com\/kb\/#website\",\"url\":\"https:\/\/www.knownhost.com\/kb\/\",\"name\":\"KnownHost\",\"description\":\"KnownHost provides a comprehensive webhosting knowledge base to help answer many of your common webhosting and linux questions.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.knownhost.com\/kb\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b\",\"name\":\"Jonathan K. W.\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g\",\"caption\":\"Jonathan K. W.\"},\"sameAs\":[\"https:\/\/www.knownhost.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":".htaccess: Invalid command '\\xef\\xbb\\xbf#' - KnownHost","description":"Learn how to solve .htaccess: Invalid command 'xefxbbxbf#' and ways to prevent that from happening in the future.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/","og_locale":"en_US","og_type":"article","og_title":".htaccess: Invalid command '\\xef\\xbb\\xbf#' - KnownHost","og_description":"Learn how to solve .htaccess: Invalid command 'xefxbbxbf#' and ways to prevent that from happening in the future.","og_url":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/","og_site_name":"KnownHost","article_published_time":"2021-06-29T12:31:58+00:00","article_modified_time":"2021-10-12T12:08:32+00:00","author":"Jonathan K. W.","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jonathan K. W.","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#article","isPartOf":{"@id":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/"},"author":{"name":"Jonathan K. W.","@id":"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b"},"headline":".htaccess: Invalid command &#8216;\\xef\\xbb\\xbf#&#8217;","datePublished":"2021-06-29T12:31:58+00:00","dateModified":"2021-10-12T12:08:32+00:00","mainEntityOfPage":{"@id":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/"},"wordCount":366,"keywords":["cloud","cpanel","dedicated","directadmin","htaccess","linux","reseller","shared","vps"],"articleSection":["Common Issues"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/","url":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/","name":".htaccess: Invalid command '\\xef\\xbb\\xbf#' - KnownHost","isPartOf":{"@id":"https:\/\/www.knownhost.com\/kb\/#website"},"datePublished":"2021-06-29T12:31:58+00:00","dateModified":"2021-10-12T12:08:32+00:00","author":{"@id":"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b"},"description":"Learn how to solve .htaccess: Invalid command '\\xef\\xbb\\xbf#' and ways to prevent that from happening in the future.","breadcrumb":{"@id":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.knownhost.com\/kb\/htaccess-invalid-command-xefxbbxbf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.knownhost.com\/kb\/"},{"@type":"ListItem","position":2,"name":".htaccess: Invalid command &#8216;\\xef\\xbb\\xbf#&#8217;"}]},{"@type":"WebSite","@id":"https:\/\/www.knownhost.com\/kb\/#website","url":"https:\/\/www.knownhost.com\/kb\/","name":"KnownHost","description":"KnownHost provides a comprehensive webhosting knowledge base to help answer many of your common webhosting and linux questions.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.knownhost.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.knownhost.com\/kb\/#\/schema\/person\/3db6e20d1f33519cd68fe0ba1230a48b","name":"Jonathan K. W.","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f432b99e6651fe8d1deb57a285bd84e806f1c9ae8b4c6c585d7e3a0b33789ad9?s=96&d=mm&r=g","caption":"Jonathan K. W."},"sameAs":["https:\/\/www.knownhost.com"]}]}},"_links":{"self":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts\/421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/comments?post=421"}],"version-history":[{"count":0,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/posts\/421\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/media?parent=421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/categories?post=421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.knownhost.com\/kb\/wp-json\/wp\/v2\/tags?post=421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}