Rewrite URLS but .htaccess is giving me trouble. Not Sure wh
Posted: Sat May 26, 2012 10:26 am
Hi Everyone,
I'm getting an internal server error when I add the .htaccess file. When I delete the file from my folder the URLS are working but when I add it I'm getting the below error. I'm attempting to rewrite my URLS. I'm trying to make them more SEO friendly. I'm trying to append the $city name from my MySql database onto my URL. Below is the error code and syntax for my pages.
http://whatsmyowncarworth.com/auto/cars.php
http://whatsmyowncarworth.com/auto/Albany <<--- I'm trying to append city names within my URLS
http://whatsmyowncarworth.com/auto/Boston
http://whatsmyowncarworth.com/auto/Massachusetts
cars.php
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I'm getting an internal server error when I add the .htaccess file. When I delete the file from my folder the URLS are working but when I add it I'm getting the below error. I'm attempting to rewrite my URLS. I'm trying to make them more SEO friendly. I'm trying to append the $city name from my MySql database onto my URL. Below is the error code and syntax for my pages.
As of right now I'm attempting to echo $city; to see if my coding is working but I wasn't expecting a internal servor problem. Any thoughts? Thanks for everyones help!Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@whatsmyowncarworth.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at whatsmyowncarworth.com Port 80
http://whatsmyowncarworth.com/auto/cars.php
http://whatsmyowncarworth.com/auto/Albany <<--- I'm trying to append city names within my URLS
http://whatsmyowncarworth.com/auto/Boston
http://whatsmyowncarworth.com/auto/Massachusetts
cars.php
Code: Select all
<?php
ob_start(); // handle redirects
include('init.php'); // connection to database
if (isset($_GET['u']))
{
$city = mysql_real_escape_string($_GET['u']);
if (ctype_alnum($city)) // protection against mysql injection
{
$data + mysql_query("SELECT State, City FROM cars WHERE City='$City'" );
if (mysql_num_rows($data===1))
{
echo $city;
}
}
}
?>Code: Select all
.htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . * - [L]
RewriteRule ^(.*)$ http://whatsmyowncarworth.com/auto/cars.php?u=$1 [NC]