This is a pretty common error appearing in the Apache servers… along with the disgusting Error 500 – Internal server error on the browser. Usually the error indicates that it was unable to send necessary header information correctly.
What makes the problem terrible – it does not explain much of the cause. The best way to solve this problem is to find your apache Log and examine it. Usually the log file is available in /var/log/apache2/error.log file in Linux.
Examine the file for a detailed description. For example, if the error message is associated with preceding –
(13)Permission denied: exec of ‘<location of the file>’ failed
– message, then your script is not marked as executable. Give file permission to run the file as executable, and your problem will be solved.
What if you can’t find the LOG file?
If you’re not allowed to access the log files in any server, then what to do? You may check the apache.conf file for the location of the log file (usually all hosting providers give access to error logs, you just need to find our where the file resides.) Ask your hosting provider for more help.
Create a .htaccess file in the directory where you want to perform the task. These settings will be applicable to sub-directories also 😉
in the .htaccess file, type the following:
RewriteRule ^([^/]+)/([^/]+)/([0-9]+)\.html$ /index.php?maindirectory=$1&subdirectory=$2&articleID=$3
The first set of parentheses will equal your first variable “$1”, the second set of parentheses will equal your second variable “$2”, etc.
The following example will not actually work because of the regular expressions however I’m putting it in here for example:
(.*)/(.*)/(.*) = $1/$2/$3
Side-Note: the reason the above example would fail with the regular expression is that the first (.*) will grab everything including the “/”. That is why I used ([^/]+) in the real example, it says grab everything but “/”.
Disable Directory Browsing
By default, Apache allows your visitors to browse through a directory if it does not has an index file. However, you can turn if off by following method:
Changing the index file name
The index file is the file that gets displayed automatically when a user browses to a directory. Historically, the index file is called index.html or index.htm. On a PHP powered site, you may want your index file to be named index.php. This can be accomplished by putting the following line in your .htaccess file:
DirectoryIndex index.php index.html
The directive above instructs Apache to use index.php as the index file if it exists, otherwise it should look for a file named index.html. If neither file exists in the requested directory, the user will usually get a directory listing.
Denying access to a directory
Sometimes, there may be directories on your website that the user shouldn’t be able to directly request files from. For example, you may have a directory that stores data files for your scripts, or a set of PHP includes. Placing the lines below in the .htaccess file for that directory will block direct requests for those files:
Deny from all
The first line ensures that the deny directive is evaluated before any allow directives that may have been defined elsewhere in the directory hierarchy.