Why is this htaccess file causing a 500 error in Apache?
Why is my htaccess file causing a 500 erro开发者_运维技巧r?
I am trying to get it so when anyone enters http://www.example.com/24 it will run the script for the 'key' 24 but the server reads http://www.example.com/?key=24.
Php script on index.php:
<?php include("scripts/config.php");
include("scripts/facebook.php");
if(isset($_GET['key'])){
$like_id=mysql_real_escape_string($_GET['key']);
include_once 'like/index.php';
}else{
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 could it be where i'm saving my htaccess file? currently its in the htdocs folder.
Try this:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?key=$1
In any case, your current rules should not trigger a 500 status code unless mod_rewrite
is not enabled.
Edit: I've just noticed that you spell it htaccess
all around the question. The correct name is .htaccess
(note the leading dot).
Error in your slashes
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)\/index$ index.php?key=$1
RewriteRule ^([a-zA-Z0-9_-]+)\/index$ index.php?key=$1
It might be looping through the rules over and over. Always add [L] unless you want the rules to be processed further.
Also, as point out by Alvaro, you don't need the / index part:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?key=$1 [L]
精彩评论