.htaccess file and 500 Internal server error
Did you know that just a harmless change in the .htaccess file can result in your page not being opened at all?
Yes. It is possible.
I will explain it in a short while. [If you do not want to read this through, please go to the last paragraph, where the solution that we found is given]
The .htaccess file, for the uninitiated, is a linux file, resident on your web server. What it does is to act on a page or the files in a folder, based upon certain rules.
Mostly developers use it for renaming a common file to something meaningful for the search engines, so that they may find it, index it and show it in search results when people look for the topic discussed on that web page.
For example, one may have a common file called products.php, which is used to show various products that the vendor sells.
Invariably, products of a certain category are grouped together. And the group code may be sent as a parameter to the file, to change the view for the visitor.
So, products.php?i=19 may show inkjet printers, products.php?i=20 may show washing machines and so on.
The name products.php?i=19 does not make much sense. It makes better sense if it were to read like "inkjet printers with less expensive toner", because we all know how the printer companies rip customers off by offering cheap printers and expensive ink cartridges.
What we use the .htaccess file is to rewrite the url to something more meaningful for the viewer as well as to the search engine, like Google search.
The whole process runs like this. The prospective visitor posts a search for "500 internal server error" in the search.
In our case, it was problems.php?i=19 and it was indexed in the search engine as "htaccess-and-500-internal-server-error", because our .htaccess file renames and rewrites all requests for the specific page problems.php?i=19 to "htaccess-and-500-internal-server-error".
Now, coming to the point. We did something like this with our page. Only a single line was changed in the .htaccess file. And from the next moment onward, the entire site starts throwing this "Error 500 Internal server error".
When we removed the line, the pages started showing properly. So, we knew that the problem 500 Internal server error is related to the one line in the .htaccess file.
A close look at the code reveals that a space has been inadvertently placed in the url rewrite line.
Instead of "htaccess-and-500-internal-server-error", it was "htaccess-and-500-internal-server- error".
Solution to htaccess induced 500 Internal server error
A space had creeped in between server and error, thus invalidating the line.
The space was removed and the problem was solved.