| |
|
| :: |
| Author |
Message |
HB phpBB SEO Team

Joined: 16 Oct 2006 Posts: 795
|
Posted: Tue Dec 26, 2006 12:41 am Post subject: More readable URLs for advanced MOD rewrite |
|
|
I understand the main motivation for the phpBB MOD rewrites is more search engine friendly URLs, but what intrigues me is the advanced MOD's more people friendly URLs. Last night while I was waiting for the little ones to settle down, I installed the MOD on a local installation. EasyMOD tripped over a couple matches and the .htaccess stuff is always tricky, but overall it went smoothly.
To get an idea of how the URLs were transformed, I perused a few hundred titles from my forum. I noticed that some URLs looked "strange" without the apostrophes, so I modified the function below to pretty them up a little, e.g.
1-000-000-000 -> 1000000
i-ll -> i will
& (ignored) -> and
they-ve -> they have OK, it's not particular sophisticated, but it does seem more readable to me. I suppose one downside of more readable URLs is less forum members will use the [url=]...[/url] tag.
| Code: | function format_url($url)
{
$url = preg_replace("(\[.*\])U","",$url);
$url = str_replace (' & ', ' and ', $url); //dan & -> -and-
$url = ereg_replace('([0-9])[,]([0-9])', '\\1\\2', $url); //dan 1,000 -> 1000
$url = ereg_replace('([A-Z])[\.]([A-Z])', '\\1\\2', $url); //dan U-S-A. -> USA
$find = array('"','\r\n','\n'); //dan removed &
$url = str_replace ($find, '-', $url);
$url = str_replace ('ß', 'ss', $url);
$url = str_replace (array('ö','Ö'), 'oe', $url);
$url = str_replace (array('ä','Ä'), 'ae', $url);
$url = str_replace (array('ü','Ü'), 'ue', $url);
$find = "ÀÁÂÃÅàáâãåÒÓÔÕØòóôõøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛùúûÿÑñ";
$replace = "AAAAAaaaaaOOOOOoooooEEEEeeeeCcIIIIiiiiUUUuuuyNn";
$url = strtr($url,$find,$replace);
$url = strtolower($url);
$url = str_replace ('\'s', 's', $url); //dan mary-s -> marys, it-s -> its
$url = str_replace ('\'t', 't', $url); //dan can-t -> cant, won-t -> wont
$url = str_replace ('\'ve', ' have', $url); //dan i-ve -> i have
$url = str_replace ('\'ll', ' will', $url); //dan i-ll -> i-will
$url = ereg_replace("[^a-zA-Z0-9]", "-", $url);
while (strstr($url, '--')) $url = str_replace('--', '-', $url);
$url = (substr($url, 0, 1) == '-') ? substr($url, 1) : $url;
$url = (substr($url, strlen($url) - 1, 1) == '-') ? substr($url, 0, strlen($url) - 1) : $url;
return $url;
} |
|
_________________ Dan Kehn |
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
HB phpBB SEO Team

Joined: 16 Oct 2006 Posts: 795
|
Posted: Tue Dec 26, 2006 2:37 pm Post subject: Re: More readable URLs for advanced MOD rewrite |
|
|
| dcz wrote: | | If it's only a matter of dealing with ', you could just replace them all with nothing instead of Hyphens like for now. |
True, but it's a language-specific issue; I wouldn't recommend that approach for English. Some contractions read well even without the apostrophe, others don't (e.g., "ill" versus "whats"). A minor change for a minor improvement, I suppose. |
_________________ Dan Kehn |
|
| Back to top |
|
 |
HB phpBB SEO Team

Joined: 16 Oct 2006 Posts: 795
|
Posted: Fri Jul 06, 2007 4:57 am Post subject: Re: More readable URLs for advanced MOD rewrite |
|
|
| Today I noticed that blogspot removes "the" / "a" / "an" and similar short words from its generated URLs. phpBB-seo URL generator may wish to follow suit. |
_________________ Dan Kehn |
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
Posted: Sun Jul 08, 2007 4:38 pm Post subject: Re: More readable URLs for advanced MOD rewrite |
|
|
we could easily remove all words being shorten than 3 characters for example.
Would be better to avoid a loop though, in format_url().
I'll perform some testing, here is already a solution without loops :
Replace :
| Code: | | $url = preg_replace( array('`[^a-z0-9]`i', '`[-]+`') , '-', $url); |
with :
| Code: | | $url = preg_replace( array('`[^a-z0-9]`i', '`-[a-z]{1,2}-`i', '`[-]+`') , '-', $url); |
in phpbb_seo_class.php, will get rid of most latin1 char set words with less than three letters. The problem is that as is, not all case will be handled, like a topic title starting with a word of less than three letters and some other exceptions.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
Xabi PR0

Joined: 20 Jun 2007 Posts: 50
|
Posted: Wed Jul 25, 2007 5:49 pm Post subject: Re: More readable URLs for advanced MOD rewrite |
|
|
| dcz wrote: | | Code: | | $url = preg_replace( array('`[^a-z0-9]`i', '`-[a-z]{1,2}-`i', '`[-]+`') , '-', $url); |
in phpbb_seo_class.php, will get rid of most latin1 char set words with less than three letters. The problem is that as is, not all case will be handled, like a topic title starting with a word of less than three letters and some other exceptions.
++ |
Could you please publish a solution that works in all cases? I'm very very interested on this. I would like to get rid of ALL words with less than 3 characters. Thank you. |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
Xabi PR0

Joined: 20 Jun 2007 Posts: 50
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
tweety PR0

Joined: 24 Jan 2007 Posts: 93
|
Posted: Sat Jul 28, 2007 7:34 pm Post subject: Re: More readable URLs for advanced MOD rewrite |
|
|
| dcz wrote: | RC3 will  |
is this for phpb2 or phpbb3
i am not sure about using phpbb3 for at least a year |
|
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 13354
|
|
| Back to top |
|
 |
|
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|