[MOD] Search Engine Friendly (SEO) URLs 1.0.0 RC4

Misc MOD Downloads for phpBB3 -- Any MOD that does not fit into any other category
Forum rules
Image Please feel free to download any MOD's here, support for each MOD is located it's own thread.

To post your own MOD, please first read the MOD Guidelines

How would you rate this mod?

Excellent!
46
64%
Very good
10
14%
Good
8
11%
Fair
2
3%
Poor
6
8%
 
Total votes : 72

[MOD] Search Engine Friendly (SEO) URLs 1.0.0 RC4

Postby Handyman » 05 Jan 2007, 22:31

Classification: Mod
phpBB Part: Forum
[style].container {width:450px;}[/style]
MOD Name: Search Engine Friendly (SEO) URLs
MOD Version: 1.0.0 RC4
Author: Handyman
MOD Description: This mod changes viewforum and viewtopic links to be SEO Friendly

Works with:
  • phpBB 3.0.0 RC7
  • All styles

Language: English

Licence: GNU General Public License v2

Installation Level: Intermediate
Installation Time: ~15 Minutes
Format: MODX
Download File: http://startrekguide.bountysource.com/downloads
Bug Tracker: http://startrekguide.bountysource.com/development

Do not post bug reports in this topic, the link is provided right above and if bug report is posted there, it will be fixed right away

Note: Your server must be able to support mod_rewrite.
To test, do the first part of the installation only (.htaccess)
and put in a url like this -> forum/test-t1.html
if it shows topic does not exist or shows the topic, then you may continue installing this mod.
If it doesn't work, you will have to setup your apache to work with mod_rewrite before installing this mod

If you like my mods, please donate to StarTrekGuide

What's new in this version:
URLs now look like this
Code: Select all
http://startrekguide.com/forum/forum-f1.html
http://startrekguide.com/forum/topic-t1.html

More complete SEO this time? no URL's slipped through the cracks in viewtopic and viewforum this time :)
Old phpbb viewtopic and viewforum links now have 301 redirect to preserve pagerank.

OPEN viewforum.php
FIND
Code: Select all
'U_LAST_POST'            => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'],    

REPLACE WITH
Code: Select all
'U_LAST_POST'            => format_url($row['topic_title'], 'p' . $row['topic_last_post_id']),    


And copy over the files from the zip replacing the old ones.


SEO Light downloaded 170 times
SEO URLS Beta 8 download 1327 times.
SEO URLS RC 1-3 downloaded 180 times.
Last edited by Handyman on 07 Jan 2008, 13:42, edited 21 times in total.
Reason: Fixed link for bug tracker
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7459
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby nedka » 05 Jan 2007, 22:59

downloading it ... thanks ^.^
User avatar
nedka
MOD Author
MOD Author
 
Posts: 47
Joined: 17 Aug 2006, 18:59
Location: Viet Nam
Gender: Male

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby angelside » 06 Jan 2007, 02:08

Thanks, I wait this function.

Pls, delete this, line 195:

#
#-----[ REPLACE WITH ]----------------
#
REPLACE WITH
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}f" . $forum_id . format_url($topic_data['forum_name'])),
#



And this function not work non-english char?

türkçe karakterlerde hata var m?
t2-t%C3%BCrk%C3%A7e_karakterlerde_hata_var_m%C4%B1.html

I use this, but don't work?

Spoiler:
Code: Select all
function format_url($url)
{
   $url = trim($url);
   $url = strtolower($url);

   $find = array('<b>', '</b>');
   $url = str_replace ($find, '', $url);

   $url = preg_replace('/<(\/{0,1})img(.*?)(\/{0,1})\>/', 'image', $url);

   $find = array(' ', '&quot;', '&amp;', '&', '\r\n', '\n', '/', '\\', '+', '<', '>');
   $url = str_replace ($find, '-', $url);

   $find = array('é', 'è', 'ë', 'ê', 'É', 'È', 'Ë', 'Ê');
   $url = str_replace ($find, 'e', $url);

   $find = array('í', '?', 'ì', 'î', 'ï', 'I', '?', 'Í', 'Ì', 'Î', 'Ï');
   $url = str_replace ($find, 'i', $url);

   $find = array('ó', 'ö', 'Ö', 'ò', 'ô', 'Ó', 'Ò', 'Ô');
   $url = str_replace ($find, 'o', $url);

   $find = array('á', 'ä', 'â', 'à', 'â', 'Ä', 'Â', 'Á', 'À', 'Â');
   $url = str_replace ($find, 'a', $url);

   $find = array('ú', 'ü', 'Ü', 'ù', 'û', 'Ú', 'Ù', 'Û');
   $url = str_replace ($find, 'u', $url);

   $find = array('ç', 'Ç');
   $url = str_replace ($find, 'c', $url);

   $find = array('?', '?');
   $url = str_replace ($find, 's', $url);

   $find = array('?', '?');
   $url = str_replace ($find, 'g', $url);

   $find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');

   $repl = array('', '-', '');

   $url = preg_replace ($find, $repl, $url);
   $url = str_replace ('--', '-', $url);

   return $url;
}
phpBB3 Portal | simple portal for phpBB3 Olympus
phpBB Türkiye | Turkish phpBB community
User avatar
angelside
MOD Author
MOD Author
 
Posts: 129
Joined: 20 Jun 2006, 03:17

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby Buzlas » 06 Jan 2007, 04:29

viewforum.php

Code: Select all
$forum_id   = request_var('f', '0');

new
Code: Select all
$forum_id   = request_var('f', 0);


viewtopic.php

Code: Select all
$forum_id   = request_var('f', '0');
$topic_id   = request_var('t', '0');

new
Code: Select all
$forum_id   = request_var('f', 0);
$topic_id   = request_var('t', 0);
Buzlas
MOD Author
MOD Author
 
Posts: 14
Joined: 02 Dec 2006, 10:48
Location: ?zmir
Favorite Team: Galatasaray (:
Gender: Male

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby Highway of Life » 06 Jan 2007, 08:00

Handyman... it should have support for full UTF-8
The problem is the URL converts unique characters to URL encoding.
So if you can allow it to decode the URL, then I think it will bypass any problems.
Watch out! I might do a code wheelie!

User avatar
Highway of Life    
STG Jedi Master
STG Jedi Master
 
Posts: 10458
Joined: 08 May 2006, 05:23
Location: Beware of Programmers carrying screwdrivers
Gender: Male
phpBB Knowledge: 10

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby Handyman » 06 Jan 2007, 08:59

OH... yeah... let me try and fix some UTF-8 stuff.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7459
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby Handyman » 06 Jan 2007, 09:59

Whew... after much testing, I came up with this
Replace the format_url in functions.php with this
Spoiler:
Code: Select all
function assign_rand_value($num)
{
// accepts 1 - 36
  
switch($num)
  {
    case
"1":
     
$rand_value = "a";
    break;
    case
"2":
     
$rand_value = "b";
    break;
    case
"3":
     
$rand_value = "c";
    break;
    case
"4":
     
$rand_value = "d";
    break;
    case
"5":
     
$rand_value = "e";
    break;
    case
"6":
     
$rand_value = "f";
    break;
    case
"7":
     
$rand_value = "g";
    break;
    case
"8":
     
$rand_value = "h";
    break;
    case
"9":
     
$rand_value = "i";
    break;
    case
"10":
     
$rand_value = "j";
    break;
    case
"11":
     
$rand_value = "k";
    break;
    case
"12":
     
$rand_value = "l";
    break;
    case
"13":
     
$rand_value = "m";
    break;
    case
"14":
     
$rand_value = "n";
    break;
    case
"15":
     
$rand_value = "o";
    break;
    case
"16":
     
$rand_value = "p";
    break;
    case
"17":
     
$rand_value = "q";
    break;
    case
"18":
     
$rand_value = "r";
    break;
    case
"19":
     
$rand_value = "s";
    break;
    case
"20":
     
$rand_value = "t";
    break;
    case
"21":
     
$rand_value = "u";
    break;
    case
"22":
     
$rand_value = "v";
    break;
    case
"23":
     
$rand_value = "w";
    break;
    case
"24":
     
$rand_value = "x";
    break;
    case
"25":
     
$rand_value = "y";
    break;
    case
"26":
     
$rand_value = "z";
    break;
    case
"27":
     
$rand_value = "0";
    break;
    case
"28":
     
$rand_value = "1";
    break;
    case
"29":
     
$rand_value = "2";
    break;
    case
"30":
     
$rand_value = "3";
    break;
    case
"31":
     
$rand_value = "4";
    break;
    case
"32":
     
$rand_value = "5";
    break;
    case
"33":
     
$rand_value = "6";
    break;
    case
"34":
     
$rand_value = "7";
    break;
    case
"35":
     
$rand_value = "8";
    break;
    case
"36":
     
$rand_value = "9";
    break;
  }
return
$rand_value;
}
function
get_random_letters($length)
{
  if(
$length>0)
  {
  
$rand_id="";
   for(
$i=1; $i<=$length; $i++)
   {
   
mt_srand((double)microtime() * 1000000);
   
$num = mt_rand(1,26);
   
$rand_id .= assign_rand_value($num);
   }
  }
return
$rand_id;
}
function
utf8_decodey($str)
{
    
$pos = 0;
    
$len = strlen($str);
    
$ret = '';

    while (
$pos < $len)
    {
        
$ord = ord($str[$pos]) & 0xF0;
        if (
$ord === 0xC0 || $ord === 0xD0)
        {
            
$charval = ((ord($str[$pos]) & 0x1F) << 6) | (ord($str[$pos + 1]) & 0x3F);
            
$pos += 2;
            
$ret .= (($charval < 256) ? chr($charval) : get_random_letters(1));
        }
        else if (
$ord === 0xE0)
        {
            
$ret .= get_random_letters(1);
            
$pos += 3;
        }
        else if (
$ord === 0xF0)
        {
            
$ret .= get_random_letters(1);
            
$pos += 4;
        }
        else
        {
            
$ret .= $str[$pos];
            ++
$pos;
        }
    }
    return
$ret;
}

function
format_url($url)
{
    
$url = str_replace (' ', '_', $url);
    
$url = "-{$url}.html";
    return
utf8_decodey($url);
}


All that does is if the string needs a special utf8 character, it changes it to a random letter or number.
I tested it with Chinese characters Wink

There's probably a better way to do this... but that will work for the moment.
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7459
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby Handyman » 06 Jan 2007, 10:19

Zip updated with the fixes posted above.
#
#-----[ REPLACE WITH ]----------------
#
REPLACE WITH
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}f" . $forum_id . format_url($topic_data['forum_name'])),
#

What's wrong with that line?
Please contact me if you have any news to submit to SCOFF News.
SCOFFing at the candidates while you sleep.
My Mods || My Mod Queue
Image
User avatar
Handyman    
Rear Fleet Admiral
Rear Fleet Admiral
 
Posts: 7459
Joined: 08 May 2006, 04:45
Location: Where no man has gone before!
Favorite Team: Seattle Seahawks
Gender: Male

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby LEW21 » 06 Jan 2007, 11:12

Faster version of assign_rand_value($num) function:
Spoiler:
Code: Select all
<?php
// @param int 1 - 36
function assign_rand_value($num)
{
$values = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
return
$values[$num - 1];
}
phpBB3.PL - User-friendly Polish phpBB 3.0 support
LEW21    
Translator
Translator
 
Posts: 901
Joined: 01 Jun 2006, 03:51
Location: Warsaw, Poland
Gender: Male
phpBB Knowledge: 10

Re: [MOD] Search Engine Friendly (SEO) URLs

Postby Highway of Life » 06 Jan 2007, 11:27

Remove the
Code: Select all
REPLACE WITH
!!
Watch out! I might do a code wheelie!

User avatar
Highway of Life    
STG Jedi Master
STG Jedi Master
 
Posts: 10458
Joined: 08 May 2006, 05:23
Location: Beware of Programmers carrying screwdrivers
Gender: Male
phpBB Knowledge: 10

Next

Return to Miscellaneous MODs, Hacks and Downloads

Who is online

Users browsing this forum: AhrefsBot, Majestic-12 [Bot] and 7 guests

cron