How to remove Byte order mark from PHP htaccess or others

What is Byte order mark (BOM)

According to W3C definition BOM is Unicode character encoding that appear as a magic number at the start of a text file or any other file types. or consider it as representation for the UTF-8 BOM in ISO-8859-1

Error Case Scenario

Sometimes you may change file using different editor software and upload that file to your website like “.htaccess or php” then on browsing the website you are getting

public_html/.htaccess: Invalid command ‘\xef\xbb\xb’, perhaps misspelled or defined by a module not included in the server configuration . Because of this error your website may not work and showing Error 500 . even if you are trying to edit the file in normal editor you wont be able to find out and remove those BOM

Remove Byte order mark (BOM)

you can login to your Linux Server using PuTTY SSH and run the following command
				
					vi .htaccess
				
			
And enter the command to remove the BOM:
				
					:set nobomb
				
			
Save the file:
				
					:wq
				
			
After running the saving command you can check the file online and the problem should be solved.
Share on facebook
Share on twitter
Share on linkedin
Share on telegram
Share on whatsapp

Related Posts