Exactly why is my htaccess file leading to a 500 error?

I'm looking to get it then when anybody makes its way into http://www.example.com/24 it'll run the script for that 'key' 24 however the server reads http://www.example.com/?key=24.

Php script on index.php:

<?php include("scripts/config.php");



include_once 'like/index.php';


include_once 'home.php';


htaccess code:

RewriteEngine On

RewriteRule ^([a-zA-Z0-9_-]+)/\index$ index.php?key=$1

RewriteRule ^([a-zA-Z0-9_-]+)/\index$ index.php?key=$1

Also can it be where i am saving my htaccess file? presently its within the htdocs folder.

Error inside your slashes

RewriteEngine On  
RewriteRule ^([a-zA-Z0-9_-]+)\/index$ index.php?key=$1  
RewriteRule ^([a-zA-Z0-9_-]+)\/index$ index.php?key=$1 

Do this:

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?key=$1

Regardless, your present rules shouldn't trigger a 500 status code unless of course mod_rewrite isn't enabled.

Edit: I have just observed that you simply spell it htaccess all over the question. The right title is .htaccess (note the key us dot).

It may be looping with the rules again and again. Always add [L] unless of course you would like the guidelines to become processed further.

Also, as explain by Alvaro, you do not need the / index part:

RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?key=$1 [L]