When a site is displaying a 500 internal server error there can be many different issues causing this to display. So the first step one should take would be to look at your Server Error logs. Make sure to make note of the time you went to the site an were presented with the sever error, this will help find the error in the log files, because there can be a lot of things logged to this file.

How to find server logs?

This can be tricky because some times on shared hosting you will not have access to your error logs, and need to have a host give you them. I would always start here or refer to the hosts documentation. Once you have access to the error logs you will want to determine the cause of the error. Now there are a lot of errors so I will just show one example below.

One 500 internal server error that you might get is caused by a the .htaccess file being misconfigured. The following is a Rewrite Rule Error.

example of an Apache Error Log Example

#Enabling the rewrite engine
RewriteEngine on 

#rewrite rule for test.php
RewriteRule ^company/([0-9a-zA-z_- &;]+) company.php?slug=$1

To fix that error one could use a tool like .htaccess checker to determine what’s wrong with the .htaccess file, but I would check out the htaccess documentation. By doing this you will actually understand what is causing the problem, and will know what the problem is without having the dependency of a tool. Then you will want to find out how to configure a rewrite rule, documentation for that can be found on the Apache website.

The next step would be figuring out how to write a regular expression to fix the problem. After you have figured regular expression’s you may write something that looks more like the following code.

#Enabling the rewrite engine
RewriteEngine on 

#rewrite rule for test.php
RewriteRule ^company/([0-9a-zA-z_\-\&]+) company.php?slug=$1
Categories
Errors
HowTo