Page 1 of 1

mod_rewrite with topic title

PostPosted: Thu Jul 27, 2006 6:30 pm
Author: maddocks
Hi,

i tried this mod which will change viewtopic.php?t=*** to the-topic-title-***.html. It includes the topic title in the rewritten url. I used this mod with IM but half of the coding it requires is missing. Anyone direct me?

[code]##############################################################
## MOD Title: phpBB SEO Advanced mod Rewrite
## MOD Author: dcz <n> http://www.phpbb-seo.com/
## MOD Description: This mod makes static URLs for phpBB
## Please read the author notes BEFORE using this mod.
## Check http://boards.phpbb-seo.com/phpbb-mod-r ... -vt43.html
## for the latest version or to get help with this MOD.
##
## MOD Version: 0.0.2
##
## Installation Level: (Advanced)
## Installation Time: 5 Minutes
## Files To Edit: (6)
## .htaccess,
## index.php,
## viewforum.php,
## viewtopic.php,
## search.php,
## overall_footer.tpl
## Included Files: n/a
##############################################################
## Author Notes:
##
## Please note that this version will not inject topic titles in post's URLS. This is to make it easier
## to disallow them with our robots.txt file, since those are duplicates any way.
## The last post link on forum Index is now statically mod rewritten postxx.html.
## People whilling to keep the old way, even though phpBB SEO does not recomand it, should read the note
## in the release thread bef ore implementing the required changes or asking for support.
##
## This mod requires running Apache Server with mod_Rewrite module loaded.
##
## This mod requires the Cyber Alien guest session mod (http://www.phpbbstyles.com/viewtopic.php?t=357) or any other SID
## removal method you may prefer.
##
## With this mod, your phpBB URL will change :
##
## index.php?c=xx => cat-title-vcxx.html
##
## viewforum.php?t=xx => forum-title-vfxx.html
##
## viewforum.php?t=xx&start=xx => forum-title-vfxx-yy.html
##
## viewtopic.php?t=xx => topic-title-vtxx.html
##
## viewtopic.php?t=xx&start=xx => topic-title-vtxx-yy.html
##
## viewtopic.php?p=xx => postxx.html
##
## profile.php?mode=viewprofile&u=xx => memberxx.html
##
## This mod has nothing in common with other phpBB mod rewrite, it will perform the URL rewriting
## without using ob_start() nor adding any SQL. It is thus faster and not messing anymore whith Gun-Zip nor with the html link format,
## and will not output any pagination duplicates.
##
## Short URL feature : everything in topic title in between "[" and "]" won't be injected in URL.
## Example :
## This topic title : "[SOMETHING] The Topic Title" will correspond to this URL : "the-topic-title-vtxx.html"
##
## Bad Title handling :
## Example :
## This topic title : """"??VÃÂÂ ©ry bÃÂÂ ¢d tÃÂÂ ¯tle handling"[hehe]!!!" will correspond to this URL : "very-bad-title-handling-vtxx.html"
##
## WARNING : Topic title injection in URL can be hard to deal with depending on the type of subjects your
## forum is about. In almost all cases phpBB SEO recommend the use of the phpBB SEO mixed mod Rewrite instead.
## Please read : http://boards.phpbb-seo.com/phpbb-seo-t ... -vt66.html
##
## This mod is and will be compatible to all phpBB SEO modules, specific install instructions may apply.
## phpBB SEO will provide patches to allow for other URL standards support upon request,
## so that everyone can take advantage of the phpBB mod Rewrites enhancement without jeopardising his Page-Ranking.
##
## Migrating from another mod Rewrite is as well possible but should be done with care to make sure you won't loose Page-Ranking.
##
####
## 0.0.1 => 0.0.2 Update : Required changes to be found in 0.0.1_0.0.2_Advanced_Update.txt
###
##
## LICENSE:
##
## We, phpBB SEO, have decided to license this mod under the RPL Licence ( http://www.opensource.org/licenses/rpl.php )
## which states you cannot remove the phpBB SEO credits and if you make any modifications you have to resubmit them
## to phpBB SEO for inclusion into this package again. You can read the license for yourself for further info.
##
## You can of course use this mod without any more limitations than those stated here and in the licence.
##
## At least a link ( http://www.phpbb-seo.com/ ) is required on every web site using this mod, or,
## if your web site does not comply with what phpBB SEO can link to, one proven link within a
## general audience hard link directory of your choice not already listing phpBB SEO.
## For more details about possible exeptions, please contact a phpBB SEO administrator (primarily SeO or dcz).
##
## Failure to comply will jeopardize support.
##
##############################################################
## MOD History:
##
## 2006-06-20 - 0.0.2
## - Will NOT inject topic titles in post(viewtopic.php?p=xx) URLs, to make it possible to disallow
## with robots.txt. Will be mod rewritten in a static manner instead.
## - Optimized the format_url() function, just doing the same job faster.
## - Added highlight fix in search.php adn fixed a small bug in search results (results posts)
## - Optimized the append_sid() filtering.
##
## 2006-05-25 - 0.0.1
## - First Beta Version
##
## 2006-03-01 - 0.0.0
## - Initial beta testing phase
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ OPEN ]------------------------------------------
#
# NOTE : Put the .htaccess file at the root level of your server.
# If you have any other rewriterules there, just put the rules in it (be careful about the order!).
# Please take a look at : http://boards.phpbb-seo.com/seo-princip ... -vt30.html
# to find out how to lock the use (or un use) of the www prefix in your domain's url.
# This is a major Search Engine Optimisation issue to take care of the www prefix issue.
#

.htaccess

#
# phpBB is installed at the root level :
#-----[ ADD ]------------------------------------------
#
# According to the specific hoster you are using, you might have to get rid of the "/"
# at the beginning of the script.php file-names like "viewforum.php".
# Make sure to change example.com with you actual domain's URL.
#

# These three lines should only be added if not already done in the .htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#########################################################
# PHPBB SEO REWRITE RULES #
#########################################################
# AUTHOR : dcz http://www.phpbb-seo.com/
# STARTED : 01/2006
#####################################################
# FORUMS PAGES
########################
# FORUM PROTECTION RULE
RewriteRule ^.+/([^/]+.html)$ /index.php [R=301,L]
# CATEGORIES
RewriteRule ^.+-vc([0-9]+).html$ /index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^.+-vf([0-9]+)-([0-9]+).html$ /viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^.+-vf([0-9]+).html$ /viewforum.php?f=$1 [QSA,L]
# PAGINATED TOPIC
RewriteRule ^.+-vt([0-9]+)-([0-9]+).html$ /viewtopic.php?t=$1&start=$2 [QSA,L]
# TOPIC
RewriteRule ^.+-vt([0-9]+).html$ /viewtopic.php?t=$1 [QSA,L]
# POST
RewriteRule ^post([0-9]+).html$ /viewtopic.php?p=$1 [QSA,L]
#PROFILES
RewriteRule ^member([0-9]+).html$ /profile.php?mode=viewprofile&u=$1 [QSA,L]
# END PHPBB PAGES
#####################################################

#
# phpBB is installed in a sud Folder :
#-----[ ADD ]------------------------------------------
#
# According to the specific hoster you are using, you might have to get rid of the "/" at the beginning of "phpbb/"
# Make sure to change phpbb/ with the actual folder name where phpBB is installed and to change example.com
# with you actual domain's URL.
#

# These three lines should only be added if not already done in the .htaccess
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

#########################################################
# PHPBB SEO REWRITE RULES #
#########################################################
# AUTHOR : DCZ http://www.phpbb-seo.com/
# STARTED : 01/2006
#####################################################
# FORUMS PAGES
########################
# FORUM PROTECTION RULE
RewriteRule ^phpbb/.+/([^/]+.html)$ /phpbb/index.php [R=301,L]
# CATEGORIES
RewriteRule ^phpbb/.+-vc([0-9]+).html$ /phpbb/index.php?c=$1 [QSA,L]
# PAGINATED FORUM
RewriteRule ^phpbb/.+-vf([0-9]+)-([0-9]+).html$ /phpbb/viewforum.php?f=$1&start=$2 [QSA,L]
# FORUM
RewriteRule ^phpbb/.+-vf([0-9]+).html$ /phpbb/viewforum.php?f=$1 [QSA,L]
# PAGINATED TOPIC
RewriteRule ^phpbb/.+-vt([0-9]+)-([0-9]+).html$ /phpbb/viewtopic.php?t=$1&start=$2 [QSA,L]
# TOPIC
RewriteRule ^phpbb/.+-vt([0-9]+).html$ /phpbb/viewtopic.php?t=$1 [QSA,L]
# POST
RewriteRule ^phpbb/post([0-9]+).html$ /phpbb/viewtopic.php?p=$1 [QSA,L]
#PROFILES
RewriteRule ^phpbb/member([0-9]+).html$ /phpbb/profile.php?mode=viewprofile&u=$1 [QSA,L]
# END PHPBB PAGES
#####################################################

#
#-----[ OPEN ]------------------------------------------
#


index.php

#
#-----[ FIND ]------------------------------------------
#

if (isset($display_categories[$cat_id]) && $display_categories[$cat_id])
{

#
#-----[ AFTER, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_cat_name = $category_rows[$i]['cat_title'];
// http://www.phpBB-SEO.com SEO TOOLKIT END


#
#-----[ FIND ]------------------------------------------
#

else
{
$l_moderators = ' ';
$moderator_list = ' ';
}

#
#-----[ AFTER, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_forum_name = $forum_data[$j]['forum_name'];
// http://www.phpBB-SEO.com SEO TOOLKIT END



#
#-----[ OPEN ]------------------------------------------
#
#

viewforum.php

#
#-----[ FIND ]------------------------------------------
#

//
// Start session management
//

#
#-----[ BEFORE, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_forum_name = $forum_row['forum_name'];
// http://www.phpBB-SEO.com SEO TOOLKIT END


#
#-----[ FIND ]------------------------------------------
#

$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];

#
#-----[ AFTER, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_topic_name = $topic_title;
// http://www.phpBB-SEO.com SEO TOOLKIT END


#
#-----[ OPEN ]------------------------------------------
#

viewtopic.php

#
#-----[ FIND ]------------------------------------------
#

$forum_name = $forum_topic_data['forum_name'];
$topic_title = $forum_topic_data['topic_title'];
$topic_id = intval($forum_topic_data['topic_id']);
$topic_time = $forum_topic_data['topic_time'];

#
#-----[ AFTER, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_forum_name = $forum_name;
// http://www.phpBB-SEO.com SEO TOOLKIT END


#
#-----[ FIND ]------------------------------------------
#
if ( count($orig_word) )
{
$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
}


#
#-----[ AFTER, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_topic_name = $topic_title;
// http://www.phpBB-SEO.com SEO TOOLKIT END


#
#-----[ FIND ]------------------------------------------
#

//
// Send vars to template
//

#
#-----[ AFTER, ADD ]------------------------------------------
# Here You can also choose not to output any highlight, which is better as far as SEO, but a bit less user-friendly.
# To do so just delete the $highlight_ok in the next replace and do not apply this one.

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$highlight_ok = ($highlight !='') ? "&highlight=$highlight" : '';
// http://www.phpBB-SEO.com SEO TOOLKIT END

#
#-----[ FIND ]------------------------------------------
#

'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&highlight=$highlight"),

#
#-----[ REPLACE WITH ]------------------------------------------
#
// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order$highlight_ok"),
// http://www.phpBB-SEO.com SEO TOOLKIT END


#
#-----[ OPEN ]------------------------------------------
#
#

search.php

#
#-----[ FIND ]------------------------------------------
#

for($i = 0; $i < count($searchset); $i++)
{


#
#-----[ AFTER, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_topic_name = $searchset[$i]['topic_title'];
$seo_forum_name = $searchset[$i]['forum_name'];
// http://www.phpBB-SEO.com SEO TOOLKIT END

#
#-----[ FIND ]------------------------------------------
#

for($i = 0; $i <count>

#
#-----[ BEFORE, ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_cat_name = FALSE;
$seo_forum_name = FALSE;
$seo_topic_name = FALSE;
// http://www.phpBB-SEO.com SEO TOOLKIT END

#
#-----[ OPEN ]------------------------------------------
#
#

includes/sessions.php

#
#-----[ FIND ]------------------------------------------
#

function append_sid($url, $non_html_amp = false)
{
global $SID;

if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') !== false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return $url;
}

#
#-----[ REPLACE WITH ]------------------------------------------
#
# In the following code changes, please look at the comments, they concern the
# mx Sitemaps Module ( http://boards.phpbb-seo.com/phpbb-seo-m ... e-vt4.html )
# and mxBB Portal. Just uncomment, to activate, or delete, if unused, the required lines of code upon your needs
#

function append_sid($url, $non_html_amp = false)
{
global $SID;
// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
global $phpEx, $seo_cat_name, $seo_forum_name, $seo_topic_name;
$amp = ($non_html_amp) ? '&' : '&';
$find = array( $amp.'start=0',
$amp.'postdays=0',
$amp.'topicdays=0',
$amp.'postorder=asc',
);
$url = str_replace ($find, "", $url);
if ( $seo_cat_name ) {
$urlin = array( "'(?)index.".$phpEx."?c=([0-9]+)(".$amp."){0,1}'",
// mx Sitemaps Module (cat URL injection)
//"'(?)sitemaps([0-9]+).html(".$amp."){0,1}'",
);
$urlout = array( "".format_url($seo_cat_name)."-vc\1.html".if_query('\2')."",
// mx Sitemaps Module (cat URL injection)
//"".format_url($seo_cat_name)."-sc\1.html".if_query('\2')."",
);
$url = preg_replace($urlin, $urlout, $url);
}
if ( $seo_forum_name ) {
$urlin = array( "'(?)viewforum.".$phpEx."?f=([0-9]+)".$amp."start=([0-9]+)(".$amp."){0,1}'",
"'(?)viewforum.".$phpEx."?f=([0-9]+)(".$amp."){0,1}'",
// mx Sitemaps Module (forum URL injection + pagination)
//"'(?)forum-map([0-9]+).html".$amp."start=([0-9]+)(".$amp."){0,1}'",
//"'(?)forum-map([0-9]+).html(".$amp."){0,1}'",
);
$urlout = array( "".format_url($seo_forum_name)."-vf\1-\2.html".if_query('\3')."",
"".format_url($seo_forum_name)."-vf\1.html".if_query('\2')."",
// mx Sitemaps Module (forum URL injection + pagination)
//"".format_url($seo_forum_name)."-fmp\1-\2.html".if_query('\3')."",
//"".format_url($seo_forum_name)."-fmp\1.html".if_query('\2')."",
);
$url = preg_replace($urlin, $urlout, $url);
}
if ($seo_topic_name) {
$urlin = array( "'(?)viewtopic.".$phpEx."?t=([0-9]+)".$amp."start=([0-9]+)(".$amp."){0,1}'",
"'(?)viewtopic.".$phpEx."?t=([0-9]+)(".$amp."){0,1}'",
);
$urlout = array("".format_url($seo_topic_name)."-vt\1-\2.html".if_query('\3')."",
"".format_url($seo_topic_name)."-vt\1.html".if_query('\2')."",
);
$url = preg_replace($urlin, $urlout, $url);
}
$urlin = array( "'(?)viewtopic.".$phpEx."?p=([0-9]+)(".$amp."){0,1}'",
"'(?)profile.".$phpEx."?mode=viewprofile".$amp."u=([0-9]+)(".$amp."){0,1}'",
// mx Sitemaps Module (mxBB map URL + pagination)
//"'(?)mx-map.html".$amp."start=([0-9]+)(".$amp."){0,1}'",
);
$urlout = array( "post\1.html".if_query('\2')."",
"member\1.html".if_query('\2')."",
// mx Sitemaps Module (mxBB map URL + pagination)
//"mx-map\1.html".if_query('\2')."",
);
$url = preg_replace($urlin, $urlout, $url);
$url = (substr($url, strlen($url) - 1, 1) == '?') ? substr($url, 0, strlen($url) - 1) : $url;
// http://www.phpBB-SEO.com SEO TOOLKIT END

if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') !== false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return $url;
}

#
#-----[ OPEN ]------------------------------------------
#
#

include/function.php

#
#-----[ FIND ]------------------------------------------
#

?>

#
#-----[ BEFORE ADD ]------------------------------------------
#

// http://www.phpBB-SEO.com SEO TOOLKIT BEGIN
function if_query($amp)
{

if($amp != '')
{
return '?';
}

}
function format_url($url)
{
$url = preg_replace("([.*])U","",$url);
$find = array('&quot;','&','rn','n');
$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 = "Ãà ¢Ã¢â‚¬Å¡Ã‚ ¬ÃƒÆ’ƒÂ

PostPosted: Mon Oct 23, 2006 3:50 am
Author: odius
figure this out yet?

Re: mod_rewrite with topic title

PostPosted: Mon Oct 23, 2006 2:06 pm
Author: Teelk
I may have webmedic's MOD rewrite that was written for IntegraMOD 1.3.x somewhere around.

I had it installed on my 1.4.0, when I had a site, and it worked wonders. I wish something like this could be added to the IM package itself, unfortunately a lot of hosts don't allow rewrite so adding it to the package was never an option.

If I can get my hands on a copy of webmedics MOD rewrite, then I can update the install instructions and rerelease the MOD.

PostPosted: Mon Oct 23, 2006 2:10 pm
Author: odius
that'd b perfect

PostPosted: Wed Oct 31, 2007 4:01 pm
Author: richiebgood
any updates on this?

PostPosted: Thu Nov 01, 2007 5:54 pm
Author: sanji
Indeed, I would be very interested. I tried once to add this mod to the 1.4.0 package, but was not successful.

It brings also a small question: what if you use this mod, and someone try to access a page with the old address : viewtopic.php?t=*** - would he be directed directly on the new page, too? Just wonder about existing links...

sanji

Re: mod_rewrite with topic title

PostPosted: Thu Nov 01, 2007 7:44 pm
Author: CaNNon
Apache does the rewrite rules on the fly, or as it's requested so the old links should get sent to the right place sanji.

PostPosted: Mon Jan 14, 2008 7:57 pm
Author: sanji
Any news on this topic? I would really very much like to use this mod rewrite stuff, so if anyone has a version he successfully installed on 1.4.1, please share with us!

sanji

PostPosted: Mon Jan 14, 2008 11:03 pm
Author: spaniel
me too - i was gonna ask for this very mod! when i ran a site using joomla it had a rewrite feature built in so computer gobbledygook became human language once more.

What would be electric tho is if the profile section could go from

website.com/profile.php?=ÂÂ £@!123444241f-23

to


website.com/[you]

there's a massive word-of-mouth (or link) benefit to such a human link - our users will add their phpbb profile to their other websites which will bring a lot more traffic and subscribers our way. I can't tell you how many websites i discovered becuase i saw a link on someone's myspace or blog, etc.

shock horror - they'll actually start to take pride in their own little phpbb-space and start filling in their profiles, i bet.



As Tom Cruise mite say: Let's done this! ;)

PostPosted: Fri Mar 07, 2008 10:17 am
Author: salmercker
hmm interesting

website.com/salmercker


you used my name for this yet i never posted in this thread lol

well until now lol

PostPosted: Fri Mar 07, 2008 12:48 pm
Author: found it
"salmercker";p="32082" wrote:hmm interesting

website.com/salmercker


you used my name for this yet i never posted in this thread lol

well until now lol


he used the you bbcode so who ever reads the thread their name will be inserted so ... if I say hi [you] then who ever reads this there name will be there in the 'you' bbcode

:mrgreen:

PostPosted: Fri Mar 07, 2008 1:12 pm
Author: salmercker
oh ok i was like hmmmmm didnt even remember about hte [.you] code lol

Re: mod_rewrite with topic title

PostPosted: Sat Mar 08, 2008 5:15 am
Author: dropstarz
Anyone got a rewrite what will work with 141? i really need one bad for my site