I am trying to program a URL Shortener in PHP. The domain adds to the db correctly and then shows itself correctly, but I just can't get the part where they go to the url and it redirects them to work. I keep getting a 500 internal error.
My .htaccess:
My go.php:Code:XBitHack Off RewriteEngine On RewriteCond %{REQUEST_URI} \/([0-9a-z]{4})$ [NC] RewriteRule ^(.*) http://localhost/go.php?%1 [L]
It is hosted on WAMP and everything seems to be good, rewrite engine is on, I'm so lost, please help!PHP Code:<?php
include ("config.php");
$i = $_SERVER['QUERY_STRING'];
if (preg_match("/^[0-9a-z]{6}$/", $i)) {
$result = mysql_query("SELECT short_url, url FROM `urls` WHERE `short_url` = '$i'") or die(mysql_error());
if (mysql_num_rows($result) < 1) {
header("Location: http://localhost/url");
exit;
}else
{
$row = mysql_fetch_row($result);
header("Location: ".$row[1]);
}
}
?>



Reply With Quote




Bookmarks