Web Hosting Talk







View Full Version : Good question, need answer :)


nikos
12-22-2004, 09:38 AM
Hello everyone,

thank you for looking in this thread.

This is my situation.

I have a forum installed at doesntmatter.com/phpBB2/

I want to move the forum to

doesntmatter.com/forum/ instead.

Althought that is very easy to do, I do have an issue.
At times when my users asked a question, other users posted a link to an older topic in the forum in the form

doesntmatter.com/phpBB2/viewtopic.php?t=1510

I want some short of script that will redirect

doesntmatter.com/phpBB2/viewtopic.php?t=1510

to doesntmatter.com/forum/viewtopic.php?t=1510


I went into the phpbb2 admin module and replaced the phpBB2 word with forum that takes care of the text, but the URL still of course links to the original phpBB2 forum.

Any ideas?

thanks,

NIkos

BlazeQ
12-22-2004, 01:40 PM
You could write a script called viewtopic.php in the phpbb2 forum that takes the 't' variable and redirects it to the appropriate page.

Would look something like this:

<? php
$t = $_get["t"];
$url = "../forum/viewtopic.php?t=$t";
header("Location: $url");
?>

Christopher Lee
12-22-2004, 02:04 PM
Might be able to do a mod_rewrite too...

nikos
12-23-2004, 02:01 AM
Can you please explain a little bit more?

I was thinking about writing a script and putting it in the phpBB2/index.php page where whenever a

phpBB2/viewtopic.php?t=1521 get linked

the page redirects

forum/viewtopic.php?t=1521

Is that all I need in the code?

Steven Dixon
12-23-2004, 08:22 AM
BlazeQ's code should be all you need actually. What he's doing is replacing the viewtopic.php in /phpBB2/ with a script that gets the id number of the topic the user was looking for (in this case 1521) and forwarding the user to the viewtopic.php in /forum/ using the same id number.

That's the most efficient way of doing it.

So basically what you need to do is move your forum, then copy his code and paste it in to notepad, save it as viewtopic.php, and upload this new viewtopic.php to your old phpbb folder.

Website Rob
12-23-2004, 08:59 AM
Using a Directive in the .htaccess might prove easier.

Rewrite /phpBB2 http://doesntmatter.com/forum

That way, it will work for "any" URL using the old directory as well as updating in Search Engines.

Christopher Lee
12-23-2004, 04:59 PM
An example article:

http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html