0

A Solution and A Question

Firstly, i would like to Thank CSGAL for this great tutorial. But there are somethings that looks bad to me. That wrong thing is "View Full Version :" Links in Arhcive pages.

For example, in arhive pages you are redirecting to "forumdisplay.php?f=123" instead of thread123.html.

And

"forumdisplay.php?f=1" instead of "keyword.html".

i've solved the forumdisplay.php issue, here is the solution:

archive/index.php:

find:

echo print_archive_navigation($foruminfo, $threadinfo);

	echo "<p class=\"largefont\">$vbphrase[view_full_version] : <a href=\"$vboptions[bburl]/showthread.php?t=$threadinfo[threadid]\">$threadinfo[title]</a></p>\n<hr />\n";

and replace with

echo print_archive_navigation($foruminfo, $threadinfo);

	echo "<p class=\"largefont\">$vbphrase[view_full_version] : <a href=\"$vboptions[bburl]/thread$thread$threadinfo[threadid].html\">$threadinfo[title]</a></p>\n<hr />\n";

That will prevent duplicate pages which may crucial for SEO. And Your "View Full Version :" links will be "thread123.html".


BUT

i couldnt solve the "forumdisplay.php?f=1" instead of "keyword.html" issue. How may i fix that problem, i just added // to :

echo print_archive_navigation($foruminfo);

	echo "<p class=\"largefont\">$vbphrase[view_full_version] : <a href=\"$vboptions[bburl]/forumdisplay.php?f=$foruminfo[forumid]\">$foruminfo[title]</a></p>\n<hr />\n";

i hope somebody help and everything work GREAT with this tutorial.

I JUST did this today


Hope that makes sense, i dont have copies of the original archive page handy to reference for the "find X, replace with X" instructions.

To see in action, check it here: www.tfw2005.com/boards/archive/

EDIT: Code wasnt showing up properly, check attached TXT file for instructions.

Attachments
Find: 

______________________________
$do = 'message';
}

?>
______________________________


(or, right before you close the first PHP set, and the HTML for the archive begins)

replace with this:

______________________________
$do = 'message';
}

// added by dani
    $foruminfo['url'] = strtolower(
     str_replace(" ", "-",
     str_replace("/", "-", $foruminfo['title'])
     )
    );
// added by dani 

?>
______________________________


Then, find

______________________________

// list threads

	echo print_archive_navigation($foruminfo);

	echo "<p class=\"largefont\">$vbphrase[view_full_version] :

______________________________

and replace the URL string following that semi colon with---

______________________________

<a href=\"$vboptions[bburl]/$foruminfo[url].html\">$foruminfo[title]</a>
______________________________
0

OK - CMPS integration: I'll give instructions based on latesttopics.php module.

But before I do, I'd like to request that people wanting modifications or additions to this hack should PLEASE make their requests HERE IN THIS THREAD, and not bug contributors via other methods. Additionally, NO ONE has my permissions to demand anything from me via any method: If I have time to contribute further to this discussion, I will do so, but I will not in future be intimidated or accept emails from people demanding that I post anything anywhere. Capiche Marcus?

I'm going to assume you have a function implemented to perform the forum/thread title parsing to create a url-friendly name format (as I recommended a while back).

In latesttopics.php, FIND:

while ($thread = $DB_site->fetch_array($threads))
	{
		if (strlen($thread['title']) > $vba_options['portal_threads_maxchars'] AND $vba_options['portal_threads_maxchars'])

Replace with:

while ($thread = $DB_site->fetch_array($threads))
	{
		$thread['url'] = mod_rewrite_title($thread['title']);
		$thread['furl'] = mod_rewrite_title($thread['forumtitle']);

		if (strlen($thread['title']) > $vba_options['portal_threads_maxchars'] AND $vba_options['portal_threads_maxchars'])

Then edit the tempalte adv_portal_latesttopicbits, FIND:

<b><a href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" title="$thread[preview]">$thread[title]</a></b>

Replace with:

<b><a href="$vboptions[bburl]/t$thread[threadid]-$thread[url].html" title="$thread[preview]">$thread[title]</a></b>

Then FIND:

<span class="smallfont"><strong><a href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" title="<if condition="$thread[preview]">$thread[preview]

</if>$vbphrase[by] $thread[postusername] <if condition="$vba_options['portal_threads_showdate']">$thread[postdate] $thread[posttime]</if>">$thread[title]</a></strong></span>

Replace with:

<span class="smallfont"><strong><a href="$vboptions[bburl]/t$thread[threadid]-$thread[url].html" title="<if condition="$thread[preview]">$thread[preview]</if>$vbphrase[by] $thread[postusername] <if condition="$vba_options['portal_threads_showdate']">$thread[postdate] $thread[posttime]</if>">$thread[title]</a></strong></span>

Then FIND:

<div class="smallfont"><a href="$vboptions[bburl]/forumdisplay.php?$session[sessionurl]f=$thread[forumid]">$thread[forumtitle]</a></div>

Replace with:

<div class="smallfont"><a href="$vboptions[bburl]/f$thread[forumid]-$thread[furl].html">$thread[forumtitle]</a></div>

You can make the similar alterations to modules currentpoll.php and news.php as well, to integrate this functionality to your vBA CMPS portal.

NOTE: this element of the guide is based on the use of the function mod_rewrite_title(): if you have not this implemented, go back and do this first.

0

Hi,

First of all thank you for making this wonderful hack, it works great, I went for basic version and will consider enhancement suggest by all of you. In short a wonderful hack.

Now is the problem I am facing. I am using sub-forums, and even I named the link forms in .htaccess file but still it is not working from forum home page and it shoing a html file name as .html no name but if I go into forum and try to go to sub form from there, it do let me access sub forum from there.

No issue is that I have over 300 sub categories/forums/sub-forums, most are hidden, and access to those are through sub forum link provided on forum home page.

Is there any way I can solve this issue, that when user click on a link forum from forum home it translate to correct address and take user to the forum instead of showing error 404 page ?

Many thanks in advance.

Regards,
Basit

Attachments urlnotworking1.jpg 39.14 KB urlnotworking2.jpg 49.38 KB
0

How would you put in place a 301 redirect for all threads in a site? The reason I ask is because google still has the old showthread.php pages.

I've also noticed that as long as the url looks like http://www.domain.com/forum/t123- whatever you have after the dash will redirect to the thread. For example:

http://www.domain.com/forum/t123-whatever.html is the same as http://www.domain.com/forum/t123-whatever-123456789.html

That may not seem like a big deal to some, but what does become a big deal is that if you have a thread you've started, then change the title of the thread, you've essentially created a new web page in google's eyes. This could result in what appears to be duplicate content because google will always be able to get to any page you've made as long as the threadid is the same, meaning t123 prefixes the dash.

0

Yes, [L] is much better than [R] for SEO reasons. By using [R], the user is actually physically redirected to the php? URL. I don't enable style changes, and have never ran into any problems with any other forum feature.

The use of [L] and [R] are completely different things. I suggest reading the mod_rewrite documentation to understand what each of the flags means. Search the docs for the string '[flags]' without the quotes, and you'll the details of each specific flag, with plenty of examples to use to help you understand them further.

That being said, [R] is the ONLY way to properly redirect the user (which is why the flag exists). I'd stick to the standards more than I'd violate them to boost SEO revenue (and yes, I know a LOT about all of this).

0

Hello Natch
Sry 4 my english... can you tell me how 2 install l this html Hack in the News Modul of vBadvanced CMPS v1.0.1? Thank you !!!

OK - CMPS integration: I'll give instructions based on latesttopics.php module.

But before I do, I'd like to request that people wanting modifications or additions to this hack should PLEASE make their requests HERE IN THIS THREAD, and not bug contributors via other methods. Additionally, NO ONE has my permissions to demand anything from me via any method: If I have time to contribute further to this discussion, I will do so, but I will not in future be intimidated or accept emails from people demanding that I post anything anywhere. Capiche Marcus?

I'm going to assume you have a function implemented to perform the forum/thread title parsing to create a url-friendly name format (as I recommended a while back).

In latesttopics.php, FIND:

while ($thread = $DB_site->fetch_array($threads))
	{
		if (strlen($thread['title']) > $vba_options['portal_threads_maxchars'] AND $vba_options['portal_threads_maxchars'])

Replace with:

while ($thread = $DB_site->fetch_array($threads))
	{
		$thread['url'] = mod_rewrite_title($thread['title']);
		$thread['furl'] = mod_rewrite_title($thread['forumtitle']);

		if (strlen($thread['title']) > $vba_options['portal_threads_maxchars'] AND $vba_options['portal_threads_maxchars'])

Then edit the tempalte adv_portal_latesttopicbits, FIND:

<b><a href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" title="$thread[preview]">$thread[title]</a></b>

Replace with:

<b><a href="$vboptions[bburl]/t$thread[threadid]-$thread[url].html" title="$thread[preview]">$thread[title]</a></b>

Then FIND:

<span class="smallfont"><strong><a href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" title="<if condition="$thread[preview]">$thread[preview]

</if>$vbphrase[by] $thread[postusername] <if condition="$vba_options['portal_threads_showdate']">$thread[postdate] $thread[posttime]</if>">$thread[title]</a></strong></span>

Replace with:

<span class="smallfont"><strong><a href="$vboptions[bburl]/t$thread[threadid]-$thread[url].html" title="<if condition="$thread[preview]">$thread[preview]</if>$vbphrase[by] $thread[postusername] <if condition="$vba_options['portal_threads_showdate']">$thread[postdate] $thread[posttime]</if>">$thread[title]</a></strong></span>

Then FIND:

<div class="smallfont"><a href="$vboptions[bburl]/forumdisplay.php?$session[sessionurl]f=$thread[forumid]">$thread[forumtitle]</a></div>

Replace with:

<div class="smallfont"><a href="$vboptions[bburl]/f$thread[forumid]-$thread[furl].html">$thread[forumtitle]</a></div>

You can make the similar alterations to modules currentpoll.php and news.php as well, to integrate this functionality to your vBA CMPS portal.

NOTE: this element of the guide is based on the use of the function mod_rewrite_title(): if you have not this implemented, go back and do this first.

0

*bump* here are the 2 Templates. I hope you can help me.
adv_portal_news_archive

<!-- News Archive -->

<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat" <if condition="$mods == 1"> colspan="5"</if>>$vba_options[portal_blockbullet] <span class="smallfont"><strong>$vbphrase[news_archive]</strong></span></td>
</tr>
<if condition="$mods == 1">
<tr>
<if condition="$vba_options">
<td class="thead" width="15">&nbsp;</td>
</if>
<td class="thead" width="100%"><span class="smallfont">$vbphrase[title_username_date]</span></td><td class="thead" width="15"><span class="smallfont">$vbphrase[replies]</span></td><td class="thead" width="15"><span class="smallfont">$vbphrase[views]</span></td>
</tr>
</if>
$newsarchivebits

</table>
<br />

<!-- End News Archive -->

& the adv_portal_news_archivebits

<if condition="$mods == 1">
<tr>
<if condition="$vba_options">
<td class="alt2"><if condition="$show"><img alt="" border="0" src="$news[threadiconpath]" title="$news[threadicontitle]" /></if>
</td>
</if>

<td class="alt1" align="$stylevar">
<if condition="$news">
<span style="float:$stylevar"><img alt="" class="inlineimg" src="$stylevar[imgdir_misc]/subscribed.gif" title="$vbphrase[you_are_subscribed_to_this_thread]" /></span>
</if>
<b><a href="$vboptions[bburl]/showthread.php?t=$news[threadid]" title="$news[preview]">$news[title]</a></b>

<div class="smallfont"><phrase 1="$vboptions[bburl]/member.php?$session[sessionurl]u=$news[postuserid]" 2="$news[postusername]">$vbphrase[by_x]</phrase>
<if condition="$news">
<span style="float:$stylevar"><img alt="" src="$stylevar[imgdir_rating]/rating_$news[rating].gif" title="<phrase 1="$news[votenum]" 2="$news[voteavg]">$vbphrase[thread_rating_x_votes_y_average]</phrase>" /></span>
</if>
</div>

<div class="smallfont">$news[postdate] <span class="time">$news[posttime]</span></div>

</td>

<td align="center" class="alt2"><span class="smallfont">$news[replycount]</span></td>
<td align="center" class="alt1"><span class="smallfont">$news[views]</span></td>
</tr>

<else />
<tr>
<td class="$getbgrow">
<if condition="$news[threadiconpath]">
<img alt="" src="$news[threadiconpath]" border="0" title="$news[threadicontitle]" />
</if>
<if condition="$news">
<img alt="" class="inlineimg" src="$stylevar[imgdir_misc]/subscribed.gif" title="$vbphrase[you_are_subscribed_to_this_thread]" />
</if>
<span class="smallfont"><b><a href="$vboptions[bburl]/showthread.php?t=$news[threadid]" title="<if condition="$news[preview]">$news[preview]

</if>$vbphrase[by] $news[postusername] $news[postdate] $news[posttime]">$news[title]</a></b></span>
<div class="smallfont">$vbphrase[last_post_by] <a href="$vboptions[bburl]/member.php?find=lastposter&amp;t=$news[threadid]">$news[lastposter]</a></div>
<div class="smallfont">$news[lastpostdate] <span class="time">$news[lastposttime]</span></div>
<div class="smallfont">$news[replycount] $vbphrase[replies], $news[views] $vbphrase[views]</div></td>
</tr>

</if>

& the News.php

<?php
// ++=========================================================================++
// || vBadvanced CMPS v1.0.1
// || © 2003-2004 vBadvanced.com & PlurPlanet, LLC - All Rights Reserved
// || This file may not be redistributed in whole or significant part.
// || http://vbadvanced.com
// || Downloaded 02:50, Thu Feb 3rd 2005 - 4204
// || 
// ++ ========================================================================++

foreach ($modules AS $omods)
{
	if ($omods['identifier'] == 'news' AND in_array($omods['modid'], explode(',', $pages['modules'])))
	{
		$shownews = true;
		$newsid = $omods['modid'];
	}
	if ($omods['identifier'] == 'newsarchive' AND in_array($omods['modid'], explode(',', $pages['modules'])))
	{
		$showarchive = true;
		$archiveid = $omods['modid'];
		$mods['modcol'] = $omods['modcol'];
		$mods[$archiveid]['displayorder'] = $omods['displayorder'];
	}
}

unset($omods);

if ($vba_options['portal_news_forumid'])
{
	if ($vba_options['portal_news_maxposts'])
	{
		if ($vba_options['portal_news_maxposts'] AND $vba_options['portal_news_enablearchive'])
		{
			$limit = $vba_options['portal_news_maxposts'] + $vba_options['portal_news_enablearchive'];
		}
		else
		{
			$limit = $vba_options['portal_news_maxposts'];
		}
		$newslimit = 'LIMIT ' . $limit;
	}

	$foruminfo['allowratings'] = $vba_options['portal_news_showrating'];

	$counter = 0;

	$getnews = $DB_site->query("
			SELECT " . iif($vba_options['portal_news_showrating'], 'IF(votenum >= ' . $vboptions['showvotes'] . ', votenum, 0) AS votenum, IF(votenum >= ' . $vboptions['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
			thread.threadid, thread.title, replycount, postusername, postuserid, thread.dateline AS postdateline, thread.lastposter, thread.lastpost, IF(views<=replycount, replycount+1, views) AS views, forumid, post.postid, pagetext, allowsmilie
			" . iif ($vba_options['portal_news_showsignature'], ', showsignature, usertextfield.signature') . "
  		" . iif ($vba_options['portal_news_showicon'] , ',thread.iconid AS threadiconid, iconpath AS threadiconpath') . " 
  		" . iif ($vba_options['portal_news_showavatar'] , ', avatarpath, NOT ISNULL(avatardata) AS hascustom, customavatar.dateline AS avatardateline, avatarrevision') . " 
  		" . iif ($vba_options['portal_news_showsubscribed'] AND $bbuserinfo['userid'] , ', NOT ISNULL(subscribethread.subscribethreadid) AS subscribed ') . " 
  		" . iif ($vba_options['portal_news_showattachments'], ', attachment.filename, attachment.filesize, attachment.visible, attachmentid, counter, thumbnail, LENGTH(thumbnail) AS thumbnailsize') . "
			FROM " . TABLE_PREFIX . "thread AS thread
			LEFT JOIN " . TABLE_PREFIX . "post AS post ON (post.postid = thread.firstpostid) 
  		" . iif ($vba_options['portal_news_showicon'] , 'LEFT JOIN ' . TABLE_PREFIX . 'icon USING (iconid)') . " 
  		" . iif ($vba_options['portal_news_showattachments'] , 'LEFT JOIN ' . TABLE_PREFIX . 'attachment AS attachment ON (post.postid = attachment.postid)') . " 
			" . iif ($vba_options['portal_news_showavatar'] OR $vba_options['portal_news_showsignature'], 
				'LEFT JOIN ' . TABLE_PREFIX . 'user AS user ON (user.userid = post.userid)
			') . "
			" . iif ($vba_options['portal_news_showsignature'], 'LEFT JOIN ' . TABLE_PREFIX . 'usertextfield AS usertextfield ON (post.userid = usertextfield.userid)') . "
  		" . iif ($vba_options['portal_news_showavatar'] , '
				LEFT JOIN ' . TABLE_PREFIX . 'avatar as avatar ON (avatar.avatarid = user.avatarid)
				LEFT JOIN ' . TABLE_PREFIX . 'customavatar as customavatar ON (customavatar.userid = user.userid)
			') . " 
  		" . iif ($vba_options['portal_news_showsubscribed'] AND $bbuserinfo['userid'] , ' LEFT JOIN ' . TABLE_PREFIX . 'subscribethread AS subscribethread ON (subscribethread.threadid = thread.threadid AND subscribethread.userid = \'' . $bbuserinfo['userid'] . '\')') . " 
			$deljoin
			WHERE forumid IN($vba_options[portal_news_forumid]) AND thread.visible = 1 AND thread.open != 10 $notdeleted
			GROUP BY post.postid
			ORDER BY " . iif($vboptions['stickynewsthreads'], 'sticky DESC,') . " postdateline DESC
			$newslimit");
	while ($news = $DB_site->fetch_array($getnews))
	{
		$counter++;

		if ($vba_options['portal_news_archivepreview'])
		{
			$news['preview'] = $news['pagetext'];
		}

		$dateposted = vbdate($vba_options['portal_news_dateformat'], $news['postdateline']);
		$news = process_thread_array($news, '', $vba_options['portal_news_showicon']);

		if ($counter <= $vba_options['portal_news_maxposts'] AND $shownews)
		{
			// Signature
			$show['signature'] = false;
			if ($vba_options['portal_news_showsignature'] AND $news['showsignature'])
			{
				$news['signature'] = parse_bbcode($news['signature'], 'nonforum', $vboptions['allowsmilies']);
				$show['signature'] = true;
			}

			// News Avatar
			$newsavatarurl = '';
			if ($vba_options['portal_news_showavatar']) 
			{
				if ($news['avatarpath']) 
				{
					$newsavatarurl = $vboptions['bburl'] . '/' . $news['avatarpath'];
				}
				else if ($news['hascustom']) 
				{
					if ($vboptions['usefileavatar'])
					{
						$newsavatarurl = $vboptions['bburl'] . '/' . $vboptions['avatarurl'] . '/avatar' . $news['postuserid']. '_' . $news['avatarrevision'] . '.gif';
					}
					else
					{
						$newsavatarurl = $vboptions['bburl'] . '/image.php?' . $session['sessionurl'] . 'u=' . $news['postuserid'] . '&amp;dateline=' . $news['avatardateline'];
					}
				}
			}

			// News Message
	
			$allowsmilie = '';
			if ($vba_options['portal_news_enablesmilies'] AND $news['allowsmilie'])
			{
				$allowsmilie = 1;
			}

			$news['message'] = parse_bbcode2($news['pagetext'], $vba_options['portal_news_enablehtml'], $vba_options['portal_news_enablevbimage'], $allowsmilie, $vba_options['portal_news_enablevbcode']);
	
			if ($vba_options['portal_news_maxchars'] AND strlen($news['message']) > $vba_options['portal_news_maxchars'])
			{
				$news['message'] = fetch_trimmed_title($news['message'], $vba_options['portal_news_maxchars']) . construct_phrase($vbphrase['read_more'], $vboptions['bburl'], $news['threadid'], $session['sessionurl']);
			}
			
			// News Attachments
			$attachment = '';
			if ($news['attachmentid'])
			{
				$newsforumperms = fetch_permissions($news['forumid']);
				if ($news['thumbnail'] AND $vboptions['attachthumbs'] AND ($newsforumperms & CANGETATTACHMENT))
				{
					$attachment = '<a href="' . $vboptions['bburl'] . '/attachment.php?' . $session['sessionurl'] . 'attachmentid=' . $news['attachmentid'] . '" target="_blank"><img border="0" src="' . $vboptions['bburl'] . '/attachment.php?' . $session['sessionurl'] . 'attachmentid=' . $news['attachmentid'] . '&amp;stc=1&amp;thumb=1" /></a>';			
				}
				else
				{
					$attachment['attachmentextension'] = file_extension($news['filename']);
					$attachment['filename'] = $news['filename'];
					$attachment['attachmentid'] = $news['attachmentid'];
					$attachment['filesize'] = vb_number_format($news['filesize'], 1, true);
					$attachment['counter'] = $news['counter'];
					eval('$attachment = "' . fetch_template('postbit_attachment') . '";');
					$attachment = str_replace('"attachment.php', '"' . $vboptions['bburl'] . '/attachment.php', $attachment);
				}	
			}

			eval('$home[$newsid][\'content\'] .= "' . fetch_template('adv_portal_newsbits') . '";');
		}
		else
		{
			eval('$newsarchivebits .= "' . fetch_template('adv_portal_news_archivebits') . '";');
		}
	}				

	if ($showarchive AND $newsarchivebits)
	{
		eval('$home[$archiveid][\'content\'] = "' . fetch_template('adv_portal_news_archive') . '";');
	}

	$DB_site->free_result($getnews);
	unset($news, $foruminfo['allowratings'], $newsarchivebits, $attachment, $counter, $newsforumbits);
}

?>
0

Hello,

I currently have a problem. I manage to install the modification but it seems that when I try to select a forum link it takes me back to my main page ( I think its an error that redirects me to the main page) It looks like the pages are being renamed to an html page but its not taking me to the appropriate page. Any ideas? Here is a copy of my .htaccess file.


Regards,

Valentine

RewriteEngine on
Options +FollowSymLinks
RewriteRule ^thread([0-9]+).html$ showthread.php?t=$1 [L]
RewriteRule ^lastpostinthread([0-9]+).html$ showthread.php?goto=lastpost&t=$1 [L]
RewriteRule ^newpostinthread([0-9]+).html$ showthread.php?goto=newpost&t=$1 [L]
RewriteRule ^forum([0-9]+).html$ forumdisplay.php?f=$1 [L]
RewriteRule ^post([0-9]+).html$ showthread.php?p=$1 [L]

0

Great hack, haven't installed it yet because I'm still weighing the benefit of having clean links against the gargantuan task of maintenancing this hack with every VB update.

Any suggestions?

0

The use of [L] and [R] are completely different things. I suggest reading the mod_rewrite documentation to understand what each of the flags means. Search the docs for the string '[flags]' without the quotes, and you'll the details of each specific flag, with plenty of examples to use to help you understand them further.

That being said, [R] is the ONLY way to properly redirect the user (which is why the flag exists). I'd stick to the standards more than I'd violate them to boost SEO revenue (and yes, I know a LOT about all of this).

After reading the documentation, I concur that L and R do mean different things. But I don't understand why [L] would be better for SEO. In fact, according to the Apache documentation referenced, it might be more appropriate to use both flags together.

0

(I hope the forum isn´t counting me out again - tried to post this a few minutes ago and the forum just logged me out and the post was gone :mad:..to hell..;) )


Hi there,

this mod_rewrite modification is truely awesome and I wanna thank those who shared their knowledge to the community.
First I gotta say - sorry for my english, I´m from germany and my english is a little bit frozen. Don´t have to use it here very often ;)

I´m running several vb3.03´s on a shared server, seperated through subdomains (All running in different subfolders and different db´s). So far as I can see I have a problem with the .htaccess-file because after uploading the modified one I´m encountering ugly error 500´s.

The server itself tells me in phpinfo that the mod_rewrite module is loaded - which means to me that the apache supports this function.

I tried to search this thread for others with the same problem - but it seems that I´m the only one. (Dani, have you already noticed that the "Search this thread"-function isn´t working correct ? It comes up with results for the entire site instead of showing results for the specific thread where you started the search.)

Therefore I´m running the boards in subfolders I uploaded one .htaccess-file in each and every board-root (modified for the specific board). Another .htaccess exists in the server-root which is pointing to the errordocuments 403, 404 and 500.

Could it be that I have to deal with rewrite_base url´s when using subforums ? At the moment my .htacces looks like this:

RewriteEngine on
   Options +FollowSymLinks
   RewriteRule ^thread([0-9]+).html$ showthread.php?t=$1 [L]
   RewriteRule ^lastpostinthread([0-9]+).html$ showthread.php?goto=lastpost&t=$1 [L]
   RewriteRule ^newpostinthread([0-9]+).html$ showthread.php?goto=newpost&t=$1 [L]
   RewriteRule ^forum([0-9]+).html$ forumdisplay.php?f=$1 [L]
   RewriteRule ^info-support.html$ forumdisplay.php?f=2 [L]
   (...)

Could anyone help me to get this thing up and running ? I just don´t see & understand what I could have done wrong..:o

Any help appreciated.

Regards,
Marv.

0

Are you using mod_alias? If so you should use the [PT] flag with mod rewrite rules.

Hi DanceInstructor,

so far as I can see mod_alias is listed as a loaded module on the server - the same way mod_rewrite is. Does this mean that I have to use the [PT] flags ? (Even if I don´t have a glue what they are used for..)

If so - could you do me a favor and show me an example how I should fix the .htaccess-file?

Regards & TIA,
Marv.

0

So far, so good. Seems that my problem discribed in the post above is solved. The reason for the error 500´s was a disabled AllowOverride (NONE) in the httpd.cfg, so we changed that to ALL. That did the trick.

By now I´m struggeling with another problem some mentioned before. The odd "domain.com/.html"-problem with subforums.
It took me some time today to read through all 13 pages of this thread, but as far as I understood - with my limited english-skills - few had the problem but nobody a solution to it. Am I wrong ?

It´s the same problem as described here http://www.daniweb.com/techtalkforums/showpost.php?p=48534&postcount=34 but unfortunality his solution and Dani´s suggestion didn´t seem to work for me.

May be I´m just snowblind :rolleyes:. Could someone have a look in my functions_forumlist.php if I made a mistake in there?

Attachments
<?php
/*======================================================================*\
|| #################################################################### ||
|| # vBulletin 3.0.3 - Licence Number [deleted]
|| # ---------------------------------------------------------------- # ||
|| # Copyright 20002004 Jelsoft Enterprises Ltd. All Rights Reserved. ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| #################################################################### ||
\*======================================================================*/

error_reporting(E_ALL & ~E_NOTICE);

// ###################### Start getiforumcache #######################
// pass $bbuserinfo[userid] into the function in order to return a value
// for which forums are subscribed ($arry[subscribeforumid])
function cache_ordered_forums($getcounters = 0, $getinvisibles = 0, $userid = 0)
{
	global $DB_site, $iforumcache, $forumcache, $_FORUMOPTIONS, $bbuserinfo;

	$forumfields = 'forum.forumid, lastpost, lastposter, lastthread, lastcategory, lastthreadid, lasticonid, threadcount, replycount';

	// query forum table to get latest lastpost/lastthread info and counters
	if ($getcounters)
	{
		// get subscribed forums too
		if ($userid)
		{
			$query = "
			SELECT subscribeforumid, $forumfields
			FROM " . TABLE_PREFIX . "forum AS forum
			LEFT JOIN " . TABLE_PREFIX . "subscribeforum AS subscribeforum ON (subscribeforum.forumid = forum.forumid AND subscribeforum.userid = $userid)
			";
		}
		// just get counters
		else
		{
			$query = "
			SELECT $forumfields
			FROM " . TABLE_PREFIX . "forum AS forum
			";
		}
	}
	// don't bother to query forum table, just use the cache
	else
	{
		// get subscribed forums
		if ($userid)
		{
			$query = "
			SELECT subscribeforumid, forumid
			FROM " . TABLE_PREFIX . "subscribeforum
			WHERE userid = $userid
			";
		}
	}

	if ($query)
	{
		$getthings = $DB_site->query($query);
		if ($DB_site->num_rows($getthings))
		{
			while ($getthing = $DB_site->fetch_array($getthings))
			{
				if (empty($forumcache["$getthing[forumid]"]))
				{
					$forumcache["$getthing[forumid]"] = array();
				}
				$forumcache["$getthing[forumid]"] = array_merge($forumcache["$getthing[forumid]"], $getthing);
			}
		}
	}

	$iforumcache = array();

	if ($getinvisibles) // get all forums including invisibles
	{
		foreach($forumcache AS $forumid => $forum)
		{
			$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
		}
	}
	else // get all forums except invisibles
	{
		foreach($forumcache AS $forumid => $forum)
		{
			if ($forum['displayorder'] AND ($forum['options'] & $_FORUMOPTIONS['active']))
			{
				$iforumcache["$forum[parentid]"]["$forum[displayorder]"]["$forumid"] = $forumid;
			}
			else
			{
				unset($forumcache["$forumid"]);
			}
		}
	}

	// do some sorting (instead of sorting with MySQL and causing a filesort)
	foreach($iforumcache AS $parentid => $devnull)
	{
		ksort($iforumcache["$parentid"]); // sort by display order
	}
	ksort($iforumcache); // sort by parentid (not actually sure if this is necessary)
}

// ###################### Start getimodcache #######################
function cache_moderators()
{
	global $DB_site, $imodcache, $mod;

	$imodcache = array();
	$mod = array();

	$forummoderators = $DB_site->query("
		SELECT moderator.*, user.username,
		IF(user.displaygroupid = 0, user.usergroupid, user.displaygroupid) AS displaygroupid
		FROM " . TABLE_PREFIX . "moderator AS moderator
		INNER JOIN " . TABLE_PREFIX . "user AS user USING(userid)
	");
	while ($moderator = $DB_site->fetch_array($forummoderators))
	{
		$moderator['musername'] = fetch_musername($moderator);
		$imodcache["$moderator[forumid]"]["$moderator[userid]"] = $moderator;
		$mod["$moderator[userid]"] = 1;
	}
	$DB_site->free_result($forummoderators);
}

// ###################### Start getlastpostinfo #######################
// this function creates a lastpostinfo array that tells makeforumbit which forum
// each forum should grab its last post info from.
// it also tots up the thread/post totals for each forum. - PERMISSIONS are taken into account.
function fetch_last_post_array()
{
	global $iforumcache, $forumcache, $lastpostarray, $bbuserinfo, $counters;

	// loop through the iforumcache
	foreach($iforumcache AS $moo)
	{
		foreach($moo AS $baa)
		{
			foreach ($baa AS $forumid)
			{

				$forum = $forumcache["$forumid"];

				// if we have no permission to view the forum's parent
				// set cannotView permissions cache for this forum and continue
				if ($cannotView["$forum[parentid]"] == 1)
				{
					$cannotView["$forumid"] = 1;
				}
				else
				{

					$forumperms = $bbuserinfo['forumpermissions']["$forumid"];

					// if we have no permissions for this forum, set the cannotView permissions cache
					// so that we don't have to check its child forums
					//if (!($forumperms & CANVIEW) OR !($forumperms & CANVIEWOTHERS))
					if (!($forumperms & CANVIEW))
					{
						$cannotView["$forumid"] = 1;
					}
					else
					{
						if (!($forumperms & CANVIEWOTHERS))
						{
							continue;
						}

						//$lastpostarray["$forumid"] = $forumid;
						if (!isset($lastpostarray["$forumid"]))
						{
							$lastpostarray["$forumid"] = $forumid;
						}
						$parents = explode(',', $forum['parentlist']);
						foreach($parents AS $parentid)
						{
							// for each parent, set an array entry containing this forum's number of posts & threads
							$children["$parentid"]["$forumid"] = array('threads' => $forum['threadcount'], 'posts' => $forum['replycount']);
							if ($parentid == -1 OR !is_array($forumcache["$parentid"]))
							{
								continue;
							}
							// compare the date for the last post info with the last post date
							// for the parent forum, and if it's greater, set the last post info
							// array for this forum to point to that forum... (erm..)
							if ((!$forum['password'] OR verify_forum_password($forum['forumid'], $forum['password'], false)) AND $forum['lastpost'] > $forumcache["$parentid"]['lastpost'])
							{
								$lastpostarray["$parentid"] = $forumid;
								$forumcache["$parentid"]['lastpost'] = $forum['lastpost'];
							}
						} // end foreach($parents)
					} // end can view
				} // end can view parent
			}
		}
	}

	$counters = array();
	if (is_array($forumcache))
	{
		foreach($forumcache AS $forum)
		{
			$counters["$forum[forumid]"]['threadcount'] = 0;
			$counters["$forum[forumid]"]['replycount'] = 0;
			if (is_array($children["$forum[forumid]"]))
			{
				foreach($children["$forum[forumid]"] AS $id => $info)
				{
					$counters["$forum[forumid]"]['threadcount'] += $info['threads'];
					$counters["$forum[forumid]"]['replycount'] += $info['posts'];
				}
			}
		}
	}
	return $i;
}

// ###################### Start makeforumbit #######################
// this function returns the properly-ordered and formatted forum lists for forumhome,
// forumdisplay and usercp. Of course, you could use it elsewhere too..
function construct_forum_bit($parentid, $depth = 0, $subsonly = 0)
{
	global $vboptions, $DB_site, $session, $bbuserinfo, $stylevar, $_FORUMOPTIONS, $vbphrase, $show;
	global $iforumcache, $forumcache, $imodcache, $lastpostarray, $counters, $inforum;

	// this function takes the constant MAXFORUMDEPTH as its guide for how
	// deep to recurse down forum lists. if MAXFORUMDEPTH is not defined,
	// it will assume a depth of 2.

	// call fetch_last_post_array() first to get last post info for forums
	if (!is_array($lastpostarray))
	{
		fetch_last_post_array();
	}

	if (!isset($iforumcache["$parentid"]))
	{
		return;
	}

	if (!defined(MAXFORUMDEPTH))
	{
		define('MAXFORUMDEPTH', 1);
	}

	$forumbits = '';
	$depth++;

	foreach ($iforumcache["$parentid"] AS $baa)
	{
		foreach ($baa AS $forumid)
		{
			// grab the appropriate forum from the $forumcache
			$forum = $forumcache["$forumid"];
			if (!$forum['displayorder'] OR !($forum['options'] & $_FORUMOPTIONS['active']))
			{
				continue;
			}

			$forumperms = $bbuserinfo['forumpermissions']["$forumid"];
			if (!($forumperms & CANVIEW) AND $vboptions['hideprivateforums'])
			{ // no permission to view current forum
				continue;
			}

			if (THIS_SCRIPT == 'index' AND $forum['subforumcolumns'] != 1 AND ($subsonly OR $depth < MAXFORUMDEPTH))
			{
				$childforumbits = construct_forum_columns($forum['forumid'], $forum['subforumcolumns']);
			}
			else if ($subsonly)
			{
				$childforumbits = construct_forum_bit($forum['forumid'], 1, $subsonly);
			}
			else if ($depth < MAXFORUMDEPTH)
			{
				$childforumbits = construct_forum_bit($forum['forumid'], $depth, $subsonly);
			}
			else
			{
				$childforumbits = '';
			}



			// do stuff if we are not doing subscriptions only, or if we ARE doing subscriptions,
			// and the forum has a subscribedforumid
			if (!$subsonly OR ($subsonly AND !empty($forum['subscribeforumid'])))
			{

				$GLOBALS['forumshown'] = true; // say that we have shown at least one forum

				if (($forum['options'] & $_FORUMOPTIONS['cancontainthreads']))
				{ // get appropriate suffix for template name
					$tempext = '_post';
				}
				else

				{
					$tempext = '_nopost';
				}

				if (!$vboptions['showforumdescription'])
				{ // blank forum description if set to not show
					$forum['description'] = '';
				}

				// dates & thread title
				$lastpostinfo = $forumcache["$lastpostarray[$forumid]"];

				// compare last post time for this forum with the last post time specified by
				// the $lastpostarray, and if it's less, use the last post info from the forum
				// specified by $lastpostarray
				if ($forumcache["$lastpostarray[$forumid]"]['lastpost'] > 0)
				{

					$lastpostinfo['lastpostdate'] = vbdate($vboptions['dateformat'], $lastpostinfo['lastpost'], 1);
					$lastpostinfo['lastposttime'] = vbdate($vboptions['timeformat'], $lastpostinfo['lastpost']);
					$lastpostinfo['trimthread'] = fetch_trimmed_title($lastpostinfo['lastthread']);

					if ($icon = fetch_iconinfo($lastpostinfo['lasticonid']))
					{
						$show['icon'] = true;
					}
0

Now, that I´ve almost spent the whole weekend in front of my computer, had uncountable talks with other vb3-fellows it seems that I can´t solve this and I´m about to give up. Even when everything else is fine - except the forumhome with all the dead /.html links.

At this point I get mad at myself that I can´t see whats going wrong here.. :mad: Or in other words: I´m really desperate and looking for help :-|

So please.. anyone ?

0

Sorry for the confusing posts - after checking all files line by line I found a "/" which doesn´t belong there.

What little signs can do...^^

0

Hi All

Thanks Dani for an excellent mod, I just have a few questions I hope someone can answer before I go ahead and isntall the mod.

Not sure if this is the case already, but I wondered if it is possible to make the mod only affect 'guests' (ie non logged in users such as search engine bots). The reason I ask is because I guess limiting it just to guests would be easier on server load(?) and won't mess around with any session ids that vB may be utilising?.

I'd appreciate your thoughts.

And thanks for writing a great article.

0

Hi,

I installed Dani's first post to the T. I am having the sub-forum problem. All subforums resolve in an error page.

Did someone find a fix to this?

Marvin, where was that /?

0

Hi guys, have been following this thread here...really like the idea of this mod and would like to give it a shot on my forums.

Just to let everyone know, Keith was generous enough to have rewritten this tutorial combining my hack as well as Ted's.

http://www.daniweb.com/tutorials/12725.html

appears the URL is broken!

0

That's the revised tutorial and it's different than Dani's. I looked and didn't see any fix to subforum issues.

0

Awsome tutorial, thanks for sharing.

I have two questions:

1. What about these "1 2 3 > Last" links that points to subsequent threads/pages? is there a way to change them to use standard URL?

2. Thread title in URL in archive, is this possible?

Thanks,
-k

0

You're referring to the new 3.0.7 one, right?

Yep. First I installed it on a test server, then exported style to xml and imported it to my real website, and voila!

-k

0

Hi, I found a problem, why my apache didnot work mod_rewrite module, I have installed it, it is my httpd.conf files

#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule status_module modules/mod_status.so
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so
#LoadModule ssl_module modules/mod_ssl.so
######Load Php Module###########

Alias /vbb "C:/Apache_Group/Apache2/cgi-bin/vbb/"

<Directory "C:/Apache_Group/Apache2/cgi-bin/vbb/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>


.htaccess files

RewriteEngine on
Options +FollowSymLinks
RewriteRule ^thread([0-9]+).html$ showthread.php?t=$1 [L]
RewriteRule ^lastpostinthread([0-9]+).html$ showthread.php?goto=lastpost&t=$1 [L]
RewriteRule ^post([0-9]+).html$ showthread.php?goto=newpost&t=$1 [L]
RewriteRule ^forum([0-9]+).html$ forumdisplay.php?f=$1 [L]


The second question is:

My website is chinese font, if I use

<a href="$forum.html"><strong>$forum[title]</strong></a>

in my vbb template, it shows bad code, like this:

http://localhost/hoopchina/vbb/鲳国嗪.html

How to resolve this problems? $forum.html

should I use <a href="forum$forum[forumid].html"> ?

0

Hullo I'm new here and must say that I'm very impressed with this mod_rewwrite.

However, I have been looking at the most updated version and am a trying to incorporate this but am confussed by the following.

I have noted this:- Below are the PHP files that need to be edited. You will notice two lines at a time. The first line represents what to search for, and the second line represents what to replace it with.

So without further ado ...

$highlightwords = '&amp;highlight=' . urlencode(implode(' ', $display['highlight']));
$highlightwords = '-' . urlencode(implode(' ', $display['highlight']));

$display['forums']["$key"] = "<a href=\"forumdisplay.php?$session[sessionurl]f=$forumid\"><b><u>" . $forumcache["$forumid"]['title'] . '</u></b></a>';
$display['forums']["$key"] = "<a href=\"forum$forumid.html\"><b><u>" . $forumcache["$forumid"]['title'] . '</u></b></a>';

showthread.php

$highlightwords = iif($goto, '&', '&amp;') . 'highlight=' . urlencode($_GET['highlight']);
$highlightwords = '-' . urlencode($_GET['highlight']);

exec_header_redirect("showthread.php?$session[sessionurl_js]p=$getlastpost[postid]$highlightwords#post$getlastpost[postid]");
exec_header_redirect("threadedpost$getlastpost[postid]$highlightwords.html#post$getlastpost[postid]");

In the above I do not know if I should delete 1 line and add several.

Jezella

Edited by Dani: Formatting fixed

0

Please ask all questions related to the new tutorial in the new tutorial thread. This tutorial is entirely different. However, each paragraph has two lines - replace the first line with the second.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.