PDA

View Full Version : mod_rewrite


kfiasche81
09-08-2005, 10:00 PM
figured it was about time I updated my mod_rewrite tutorial for vBulletin. Therefore, I decided to provide you guys with the exact, full mod_rewrite that I use here at DaniWeb. It's written for a clean install of vB 3.0.7. This version is not for the faint of heart!

Some new features you can expect to find in this version, that aren't in previous versions, included multi-page support, support for linear, hybrid, and threaded thread modes, full support in the who's online (no more Unknown Locations!), previous / next thread links, and much more!

Attached is my massive .htaccess file. Rename it .htaccess and upload it to your forum directory. Also attached is an .xml file that contains all of the templates that need to be changed. They are already fully edited. Use the vB Admin Panel to create a new style out of the attached XML file. Then, simply edit it as you'd like. However, for the most part, CSS customizations will do - most of what I accomlish at DaniWeb is mere changing the CSS and the header and footer templates.

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 ...

forumdisplay.php


$navbits["forumdisplay.php?$session[sessionurl]f=$forumID"] = $forumTitle;
$navbits["forum$forumID.html"] = $forumTitle; // edited by Dani

$announcementidlink = iif(!$vboptions['oneannounce'] , "&announcementid=$announcement[announcementid]");
$announcementidlink = iif(!$vboptions['oneannounce'] , "-$announcement[announcementid]");

$pagenav = construct_page_nav($totalthreads, "forumdisplay.php?$session[sessionurl]f=$forumid", "&sort=$sortfield&order=$sortorder&pp=$perpage&days prune=$daysprune");
$pagenav = construct_page_nav($totalthreads, "forum$forumid", "-$sortfield-$sortorder-$perpage-$daysprune.html");




search.php


$highlightwords = '&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]");

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

exec_header_redirect("showthread.php?$session[sessionurl_js]t=$threadinfo[threadid]&goto=lastpost$highlightwords");
exec_header_redirect("lastpostinthread$threadinfo[threadid]$highlightwords.html");

exec_header_redirect("showthread.php?$session[sessionurl_js]t=$thread[pollid]");
exec_header_redirect("thread$thread[pollid].html");

$pagenav = construct_page_nav($totalposts, "showthread.php?$session[sessionurl]t=$threadid", "&amp;pp=$perpage$highlightwords");
$pagenav = construct_page_nav($totalposts, "threadnav$threadid", "-$perpage$highlightwords.html");

$firstunread = 'showthread.php?' . $session['sessionurl'] . 't=' . $threadid . '&goto=newpost';
$firstunread = 'newpostinthread' . $threadid . '.html';

$pagenav = construct_page_nav($numhybrids, "showthread.php?$session[sessionurl]p=$_REQUEST[postid]", "&amp;pp=$perpage$highlightwords");
$pagenav = construct_page_nav($numhybrids, "post$_REQUEST[postid]", "-$perpage$highlightwords.html");

$navbits["forumdisplay.php?$session[sessionurl]f=$forumID"] = $forumTitle;
$navbits["forum$forumID.html"] = $forumTitle;



clientscript/vbulletin_thrdpostlist.js


window.location = "showthread.php?" + SESSIONURL + "postid=" + postid + "#poststop";
window.location = "post" + postid + ".html#poststop";

document.write('<a href="showthread.php?postid=' + postid + highlightwords + '#post' + postid + '" id="link' + postid + '"><i>' + morephrase + '</i></a></div>\n');
document.write('<a href="threadedpost' + postid + highlightwords + '.html#post' + postid + '" id="link' + postid + '"><i>' + morephrase + '</i></a></div>\n');

document.write('<a href="showthread.php?postid=' + postid + highlightwords + '#post' + postid + '" onclick="return showPost(' + postid + ')" id="link' + postid + '"' + titlestyle + '>' + title + '</a> ');
document.write('<a href="threadedpost' + postid + highlightwords + '.html#post' + postid + '" onclick="return showPost(' + postid + ')" id="link' + postid + '"' + titlestyle + '>' + title + '</a> ');



includes/functions_forumdisplay.php


$address = "showthread.php?$session[sessionurl]t=$thread[threadid]";
$address = "threadnav$thread[threadid]";

$address2 = "$thread[highlight]";
$address2 = "-$vboptions[maxposts]$thread[highlight].html";


includes/functions_online.php


$userinfo['where'] = "<a href=\"showthread.php?$session[sessionurl]t=$threadid\" title=\"$threadpreview\">$threadtitle</a>";
$userinfo['where'] = "<a href=\"thread$threadid.html\" title=\"$threadpreview\">$threadtitle</a>";

$userinfo['where'] = "<a href=\"showthread.php?$session[sessionurl]p=$postid#postid=$postid\" title=\"$threadpreview\">$threadtitle</a>";
$userinfo['where'] = "<a href=\"post$postid.html#post$postid\" title=\"$threadpreview\">$threadtitle</a>";

$userinfo['where'] = "<a href=\"forumdisplay.php?$session[sessionurl]f=$forumid\">$forumtitle</a>";
$userinfo['where'] = "<a href=\"forum$forumid.html\">$forumtitle</a>";



Also, in functions_online.php, after

$userinfo['values'] = $values;

insert


// added by dani for seo hack
if (eregi("thread([0-9]+).html$", $filename, $tmatch))
{
$filename = 'showthread.php';
$values['threadid'] = $tmatch[1];
}

if (eregi("forum([0-9]+).html$", $filename, $fmatch))
{
$filename = 'forumdisplay.php';
$values['forumid'] = $fmatch[1];
}

if (eregi("post([0-9]+).html$", $filename, $pmatch))
{
$filename = 'showthread.php';
$values['postid'] = $pmatch[1];
}
if (eregi("post([0-9]+).html#post([0-9]+)$", $filename, $pmatch))
{
$filename = 'showthread.php';
$values['postid'] = $pmatch[1];
}
// added by dani for seo hack


TNX to dani..

bigcurt
09-09-2005, 06:43 PM
Umm, first I believe this has already been released, also did you ask Dani before releasing her code here? I just wanted to make sure, so just tell me.

~Curt

GoTTi
09-10-2005, 01:21 AM
whats this do?

djr
09-10-2005, 10:34 AM
- edit: Sorry, was being stupid.
whats this do?This is for SEO purposes. It's essentialy serving search engine spiders static url's rich with (high) keyword density.

italks
09-17-2005, 05:48 PM
will this work on vBulletin 3.0.6 ???