...

View Full Version : How to change url structure?



TurkzZ
05-26-2011, 01:32 AM
Ok this is my site http://www.turkish-football.com/ , and when i click on a link it currently comes up as:

http://www.turkish-football.com/news_read.php?id=315

now instead of the whole ID thing id rather the name of the article came up, however when i try to do it, it comes up as egemen%20Korkmaz and so on, and doesnt work

how do i change the URL structure so the article name comes up and not some ID, i hear this is good for SEO as well

thanks

Puppet Master
05-26-2011, 01:39 AM
You can make the query get the title rather than the id. You can also use a URL rewrite condition, the that's with an apache script I think.

TurkzZ
05-26-2011, 02:03 AM
i tried getting the query to get the title but it came up with the %20 between the words and didnt work, ill give another shot now, what's the URL rewite condition? would that mean that there would be two links to each article?

TurkzZ
05-26-2011, 02:08 AM
currently the query goes:

on the home page click each news has a link as the following:

<a href='news_read.php?id=$row[id]'> <img src=admin/mainnewsimg/".$row['photo'] ." alt='$title' width='125' height='85'> </a>

and on the news page where it displays the news:


<?php
if(isset($_POST['submit']))
{
}
elseif(isset($_GET['id']))
{
$result = mysql_query("SELECT * FROM news WHERE id='$_GET[id]' ",$connect);

while($row = mysql_fetch_assoc($result))
{
$title = stripslashes($row["title"]);
$summary = stripslashes($row["summary"]);
$body = stripslashes(nl2br($row["body"]));
$date = $row['date'];
$pic = $row['photo'];
$id = $row['id'];
$date = date("d M Y");
}
}
?>

and to display the news:

<?php
//display data


echo "<h1 class='headline_header_font'>".$title."</h1>";
echo "<h4 class='date'>$date</h4><hr>";
echo "<img src=admin/mainnewsimg/$pic alt='$summary' width='275' height='155' class='news_img'>";
echo "<p>$body</p>";
echo "<br>";
?>

TheMachineWare
05-26-2011, 05:29 PM
The way I worked around this is to replace the spaces in the title with a underscore. The %20 is a space.

I currently use the rewrite on my site and then also use php to decode the url and transform my links from a easily readable text link to ?=id=somevalue.

This is a good way I have found to work with this. the underscore is a great for this purpose.

Feel free to contact me and I can help you out more.

TurkzZ
05-26-2011, 07:16 PM
hmmm even in the url if i replace the %20 with _ it doesn't pull the data from DB, if poss could you post an example of the code used on a link so i can compare,

MattF
05-26-2011, 10:56 PM
hmmm even in the url if i replace the %20 with _ it doesn't pull the data from DB, if poss could you post an example of the code used on a link so i can compare,

You need to return the underscore to a space before you make your query against the DB.

TurkzZ
05-27-2011, 12:20 AM
ok this whole url structure has confused me, am I meant to change something in the .htaccess file lol, im stumped by this one



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum