Jump to content

PHP mySQL SEO URL Building help.


monkeytooth

Recommended Posts

Morning..

I have a database full of records, in the hundreds of thousands if not more. These records I think were never intended to be used as part of a web application, or at least thats what I assume. That or this thing is rather dated. I'm not sure either way. But that doesn't matter I have been charged with the task of making it SEO Friendly. Can't say I am to sure as where to begin with the idea. This is a database of books (titles, authors, print date, and so on).

 

Now what I am expected to pull off in all this is the ability to create a URL like:

 

http://www.domain.com/book/title/title-of-the-book/

Now I know how to work the magic with .htaccess, use php scripting to my advantage with a URL like that. However my issue is the titles themselves. They are hardly to say the least "Sanatized"

 

Javascript&Ajax

HTML, Xhtml and Css: Visual Quickstart Guide

Intro. to Econometrics, Brief Edition

Wie Geht's? - With CD

Puentes  - With 2 CD's

 

Above is just a couple of samples from the title column of the database. As you can see there are a handful of characters in those titles that could break the URL and even scripts they will run through.

 

What I am gathering is my best bet is to create another column on the table and use it for friendly variations of those titles, by friendly I mean

 

Javascript-Ajax

HTML-Xhtml-and-Css-Visual-Quickstart-Guide

Intro-to-Econometrics-Brief-Edition

Wie-Gehts-With-CD

Puentes-With-2-CDs

 

Where I am stuck is what is "URL/Script" Safe, and what isn't I mean I have a general grasp on deffinantely things not to use. But would anyone be willing to help me figure out a way to filter the original titles and widdle them down to its equivalents. I only ask cause I am working with a serious ammount of records, I know im going to run into time outs if i just try to run it on the full tables worth of data, I also know Im sure what ever filter I might make to do this might be missing key things that I want to prevent. So any ideas would be very helpful

 

Thank you in advance for any advice, help, etc any of you may have to offer..

 

Link to comment
https://forums.phpfreaks.com/topic/197989-php-mysql-seo-url-building-help/
Share on other sites

Sorry, to just bump this.. but this is something I am seriously curious about, and I dont even know where to begin. Im just looking for idea's. Even if someone can tell me what that type of URL is called so I can search for it myself Ill be happy with that. :-)

Sorry, to just bump this.. but this is something I am seriously curious about, and I dont even know where to begin. Im just looking for idea's. Even if someone can tell me what that type of URL is called so I can search for it myself Ill be happy with that. :-)

 

They're called url slugs, Here is an example:

function slug($str)
{
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return $str;
}

 

I'm sure there are many many many many examples online, as WP/Virtually every other CMS out there utilizes them.

I see you're working with German titles too, If in case there's an accented character you can always use iconv:

$string = "ABBĀSĀBĀD";

echo iconv('UTF-8', 'ISO-8859-1//IGNORE', $string);
// output: ABBSBD

echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $string);
// output: ABBASABAD

Thanks oni-kun, I will definitely be looking into Slugs a bit more, and thank you for giving me a start point and suggesting the char conversion function, I don't think I knew about that one, but makes good sense. Ill have to take a better look at the database see how many titles are with non us char's.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.