SMF Support > vBulletin

Aliasing old VB postURLs to SMF URLs

(1/4) > >>

MrMike:
I'm converting a VB forum to SMF and I'm wondering if it's possible to alias or redirect the old URLs to the SMF URLs, which are slightly different.

Old VB style URLs:
http://www.domain.com/staff-area/87846-posting-rules.html

Converted SMF URLs:
http://www.domain.com/forum/index.php?topic=87846.0

Is there a way, perhaps with htaccess to redirect the old URLs to the new URLs? The post IDs are the same and I'm trying to avoid the massive number of 404s that are going to result when the URLs to 250,000 posts suddenly change.

I'm thinking something like Simple SEF might help to mitigate this somewhat by making the URLs similar.

Maybe use htaccess to direct 404 errors to a php script that'll reformat the URLs and redirect the users to the correct post?

Suggestions would be welcome.

Oldiesmann:
It should be quite easy to do that with .htaccess, but unfortunately I'm not very knowledgeable on that subject. I'll see if I can point someone who knows more about mod_rewrite in this direction :)

IchBin™:
Hmmm... been a long time since I messed with these things. Maybe try something like this:

--- Code: ---RewriteRule ^staff-area/([0-9]+)$   forum/index.php?topic=$1 [R=301,L]
--- End code ---


Cross your fingers and hope it works. :D

MrMike:
I coed a simple solution for this. I set my 404 page to 404.php, and inside 404.php I placed this code (crude, but it works). It just silently forwards the user to the topic without any fuss.


--- Code: ---<?php
// reformat old-style VBulletin links to SMF-style links

$qstring = $_SERVER['REQUEST_URI'];
$pattern = '|/(\d+)-|';
preg_match($pattern, $qstring, $matches, PREG_OFFSET_CAPTURE, 3);

$topic_id = $matches[1][0];

// make new link
$new_url = "http://www.domain.com/index.php?topic=$topic_id";

print <<<EOM
<html>
<head>
<meta http-equiv="refresh" content="0;url=$new_url"> 
</head>
<body>
</body>
</html>
EOM;

?>
--- End code ---

Oldiesmann:
Use this code instead of that big print section... Takes up less space...


--- Code: ---header('Location: ' . $new_url);
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version