Tuesday, August 25, 2020

.htaccess file issue

.htaccess file issue

Typically this problem will generate an error message like the one below in the error_log file of the Apache server:

Invalid command '\xef\xbb\xbf#', perhaps misspelled or defined by a module not included in the server configuration

The reason is most probably that you are editing .htaccess file using Windows Notepad. Notepad is configured per default to save files with BOM. The Apache server does not expect this format and will generate an error. The file shall be pure UTF-8.

Solution: change the file editing software to Notepad ++ (open source file editing SW)...

...BUT this is not straightforward.

(Step-by-step guide for Win10, NPP 7.8.9, NppFTP 0.29.6)

Step 1)
Notepad++ 's extension NppFTP enables remote FTP file editing. You will need to install it.

And then open the NppFTP window

Step2) 
Configure your FTP access

Step3)
Browse to the FTP folder where the .htaccess file is located...but you will not find it. Per default Npp does not display them. You will need to configure the option of the plug-in

Step 4)
Browse  to C:\Users\YourName
and enable "Hidden Items"
You should now see a folder called "AppData"

Step 5)
Go to:
C:\Users\YourName\AppData\Roaming\Notepad++\plugins\Config\NppFTP
and open NppFTP.xml in windows NotePad (and not Notepad++)

Step 6)
Identify the FTP profile within the xml code:

In the example above -> the 4th line from the top

Then within this line find the listParams attribute and add -al as depicted below:

P.S. This manual change is required for every (new) profile / ftp connection

Step 7)
Restart Npp and you should now be able to edit .htaccess file on a remote FTP server

Step 8)
Open the .htaccess file and change the encoding to pure UTf-8 as depicted below (with the convert to UFT-8 function)

Step 9)
Save the file, and test if the problem disappeared

No comments:

Post a Comment