Jump to content

Rewrite URLS but .htaccess is giving me trouble. Not Sure why?


mcc_22ri

Recommended Posts

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.

 

(I uploaded the .htaccess so you can view the error code)

 

Error code

 

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

 

 

 

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!

 

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

 

<?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;
}
  }
}
?>

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

 

.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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.