Tutorial on custom rewrites/changing rewrtires
The first thing is first, back up all files!
The next thing you want to decide if you are doing a new rewrite or modifying an existing one. Either way, we will need to modify the .htaccess mod_rewrite rules. If you are modifying an already existing one, try and find which rule it is (it is pretty self-explanatory, the (.*) and $# represent variables in the rewrite). If you are creating a new one, copy off of one and use it as a template.
RewriteRule ^f-(.*)-(.*).html forumdisplay.php?f=$2 [L]
What this is telling us, is anything that starts with an f and then has two variables - separated by a hyphen applies to this rewrite. Since we don't care about the name of the forum, we only want the $2 aka the ID of the forum. Let's say we want it to be forumid.html. We will need to rewrite the rule to be:
RewriteRule ^forum(.*).html forumdisplay.php?f=$1 [L]
It really is that simple! Before we continue, you want to make sure you have the rule correct. Just go to yourforum.com/forum(some real id here).html. Does it work? If it does, then you did it correctly (and if you used that example) otherwise don't go on until you perfected that rewrite rule.
Now this is where the fun begins at. We will need to modify the plugin, but for member/showthread/forumdisplay there are an if statement to decide if we are on that. So if you are modifying any of these three, go to vB Options->vRewrite and choose the first rewrite option. We do not want the second!
Now go to ACP->Plugin Manager->vRewrite under global_complete. Edit it. This is where it gets messy so I would suggest playing with it on a test vB first, and then just copy and paste the code over. It's very easy to make a small mistake and cause a white page (aka a parse error).
Each rewrite rule is commented out like so:
#------------------------------
# Replace Forums
#------------------------------
But first we see
Code:
if($vbulletin->options['vRewrite_forumrewrite'] == "2") {
This is what I was talking about earlier. If you are using any of the 3 discussed above, skip down until you see the second one (in this case the second replace forums). There are only two for forumdisplay/showthread/member.
Here is what mine says now.
PHP Code:
#------------------------------
# Replace Forums
#------------------------------
$found = preg_match_all('#<a href="forumdisplay\.php\?f=([0-9]+)"#i', $output, $matches);
if($found)
{
// Build an array of ID's
$ids = array();
for($i = 0; $i < $found; $i++)
{
$fid = $matches[1][$i];
if(!array_key_exists($fid, $vbulletin->forumcache))
continue;
$f = $vbulletin->forumcache[$fid];
$fid = $f['forumid'];
$title = urlize($f['title']);
$output = str_replace("<a href=\"forumdisplay.php?f=$fid\"", "<a href=\"f-$title-$fid.html\"", $output);
}
}
Now we don't worry about anything besides the str_replace. The first part of the str_replace stays the same. However, the second part you see:
PHP Code:
"<a href=\"f-$title-$fid.html\""
Using our example from above, we would change this to:
PHP Code:
"<a href=\"forum$id\""
It really is that simple! You just got to be very careful when you upgrade vRewrite. Any questions, please keep 'em in the thread as I "technically" don't support this, but I may not notice