How to resolve a file.htaccess?

If I add a file .htaccess, then the site crashes, the browser displays:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Author: Max, 2012-03-04

5 answers

In the configs of the apache domain, revraits must be allowed:

AllowOverride ALL

Bring this config file here. I had the same problem on VDS, it was solved by this line.

 4
Author: Ёхарный Бабай, 2012-03-05 05:58:52

Most likely, mod_rewrite is commented out in the configs

 1
Author: kemerov4anin, 2012-03-05 00:48:54

If the file . htaccess is empty, then delete it nafig, if it is really needed for something, then write these necessary lines in it, otherwise the error will remain.

Well, or write in it

RewriteEngine on
RewriteBase /

In general, you can throw off the Apache log file, and it will be much clearer there because of what the error crashes. Nothing is clear without logs. It is quite possible that .htaccess is not empty, that it contains some string, or is stored in UTF-8 bom. which is most likely to give an error. I can write a car and a cart, and the meaning? The file code is here, the apache log is also here :)

But still possible in the Apache config is disabled.

 1
Author: Artem, 2012-03-05 10:29:15

Remove the # character at the beginning of line 156 in apache\conf\httpd.conf. And write AllowOverride All on lines 229, 265, 378 (line numbers may differ).

 1
Author: Ilia, 2016-06-09 06:13:45

When the software product has the ability to view the error log, then when an error occurs, you should:

  1. Translate the error text in the log and do what is asked, if it does not cause difficulties;
  2. And / or immediately enter a piece of the error text in the log into the search engine and see how others solved the problem;
  3. If options 1 and 2 did not help, ask the question, give it the text of the error in the log.

Specifically for Apache - more precisely, I have it WampServer, which includes Apache - I have always been helped several times by method 1. The error description in the log is quite detailed and clear.

Without the contents of the log, it is impossible to say exactly what the problem is, 500 Internal Server Error can be issued for several reasons. Judging by the results I got when I Googled for a solution to a similar problem, most users are helped by replacing the httpd.conf line in the #LoadModule rewrite_module modules/mod_rewrite.so file with LoadModule rewrite_module modules/mod_rewrite.so.

Personally, it helped me deleting all comments in .htaccess, solved the problem by sorting out the log.

 1
Author: Саша Черных, 2017-04-13 12:53:25