More readable URLs for advanced MOD rewrite

Discussions and support about the different URL Rewriting techniques for phpBB2.

Moderator: Moderators

More readable URLs for advanced MOD rewrite

Postby HB » Tue Dec 26, 2006 12:41 am

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: Select all
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
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1504
Joined: Mon Oct 16, 2006 2:25 am

Advertisement

Postby dcz » Tue Dec 26, 2006 10:23 am

If it's only a matter of dealing with ', you could just replace them all with nothing instead of Hyphens like for now.

Adding :

Code: Select all
   $url = str_replace ("'", '', $url);


After :

Code: Select all
   $url = str_replace (array('ü','Ü'), 'ue', $url);



But be careful, even with the zero dupe you don't want to change all of your urls every other day.


++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby HB » Tue Dec 26, 2006 2:37 pm

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
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1504
Joined: Mon Oct 16, 2006 2:25 am

Postby HB » Fri Jul 06, 2007 4:57 am

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
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1504
Joined: Mon Oct 16, 2006 2:25 am

Postby dcz » Sun Jul 08, 2007 4:38 pm

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: Select all
      $url = preg_replace( array('`[^a-z0-9]`i', '`[-]+`') , '-', $url);


with :

Code: Select all
      $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 || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby Xabi » Wed Jul 25, 2007 5:49 pm

dcz wrote:
Code: Select all
      $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.
Xabi
PR0
PR0
 
Posts: 54
Joined: Wed Jun 20, 2007 2:29 pm

Postby dcz » Fri Jul 27, 2007 5:50 pm

RC3 will ;)
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby Xabi » Fri Jul 27, 2007 5:52 pm

:shock: I definitely NEED that RC3 version! Please check my last messages at http://www.phpbb-seo.com/boards/advance ... html#10301
Xabi
PR0
PR0
 
Posts: 54
Joined: Wed Jun 20, 2007 2:29 pm

Postby dcz » Fri Jul 27, 2007 7:25 pm

Maybe you' be lucky, but honestly, I cannot tell, keep faith ;)
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm

Postby tweety » Sat Jul 28, 2007 7:34 pm

dcz wrote:RC3 will ;)


is this for phpb2 or phpbb3


i am not sure about using phpbb3 for at least a year
tweety
PR0
PR0
 
Posts: 94
Joined: Wed Jan 24, 2007 1:29 am

Postby dcz » Fri Aug 03, 2007 2:50 pm

phpBB3 for now, but we'll soon back-port all the new feature developed while playing with phpBB3 ;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21325
Joined: Fri Apr 28, 2006 9:03 pm


Return to phpBB2 mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 5 guests