Search code examples
apache.htaccess

Apache reads only the first line of .htaccess


I have a .htaccess file with text

RewriteEngine On
DirectoryIndex default.html

The problem is that when the site loads, default.html is not loaded, and when I tried to write like this:

DirectoryIndex default.html
RewriteEngine On

Then the site began to load, but all subsequent rules did not. Moreover, even if the first line is a comment, the subsequent ones are also not loaded. What can be done? Thanks in advance.


Solution

  • The error was in the encoding. Unix uses a line break of the form \n, while MacOS uses \r, which is why only the first line was read. The solution is to simply copy the contents of the file, recreate it and paste it back with the required encoding.