Redirect old URLs to the new forum URLs

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
fax8
Posts: 61
Joined: Mon Feb 14, 2011 5:29 pm

Redirect old URLs to the new forum URLs

Post by fax8 »

MultiWii forum has been recently moved from http://wbb.multiwii.com/ to http://www.multiwii.com/forum/ .. I'm not sure why this has been done.. however this moving broke all the links to the old forum urls.

However, there seems to be a direct mapping from the old URLs to the new URLs.
Eg: http://wbb.multiwii.com/viewtopic.php?f=8&t=471 became http://www.multiwii.com/forum/viewtopic.php?f=8&t=471

That said, is pretty straight forward to write a URL Rewrite rule for Apache's ModRewrite which would convert old URLs to the new path.

This can be accomplishied by the following rules, to be inserted in the .htaccess file in the web root for the domain wbb.multiwii.com

Code: Select all

RewriteEngine on
RewriteRule ^(.*)$ http://www.multiwii.com/forum/$1 [R=301,L]


This way, any request to the old URLs will be forwarded to the new address without any broken link.

Hope this helps,

Fabio Varesano

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Redirect old URLs to the new forum URLs

Post by Alexinparis »

Hi Fabio,

The initial forum was brought up to life with the help of a friend.
But the method he used was to activate a one click install from dreamhost (the web hosting solution supplier).
This method didn't allow me to have access to the installed files as they are shared among all one click forum installs. (only the database is unique for each install)

There was a bug lasting several month some time ago which gave a timeout after a post. It was impossible to solve this bug because I had no access to the configuration files.
I think it was quite risky to continue like this.

So I decided to make my own install from scratch on the main site repository.
I managed to migrate the database and the attachments (except the avatars).

The fact it's impossible for me to modify the previous forum (putting a .htaccess) is precisely one of the reason for this new forum where I can customize exactly what I want ;)

demands
Posts: 35
Joined: Fri Jul 22, 2011 8:59 am
Location: Linköping, Sweden

Re: Redirect old URLs to the new forum URLs

Post by demands »

Common problem, when you move from a public hosted to a private solution... Personally I don't think it's much of an issue, but I'll throw in two different suggestions:

Since you have access to the DB on this new forum, one way would be to simply create a script which will search/replace "wbb.multiwii.com/" with "www.multiwii.com/forum/" in all posts stored in the DB... A bit dangerous if you're not sure of what you're doing ;) Have a backup ready just in case. Shouldn't be to hard (I assume that it's a *SQL server)... A shell/python/perl/php script would do the trick quite fast...

Yet another way would be to use the Apache module "mod_substitute" (http://httpd.apache.org/docs/2.2/mod/mo ... itute.html) which will allow you to do search/replace rewrite of the generated HTML response body before it's sent from the server to the client upon request.

//demands

fax8
Posts: 61
Joined: Mon Feb 14, 2011 5:29 pm

Re: Redirect old URLs to the new forum URLs

Post by fax8 »

demands, your solutions looks good but I'd go with something simpler. Hacking the DB and output HTML is error prone and won't work for inbound urls from external websites.

First, disinstall the dreamhost installed forum and the associated sub domain wbb.multiwii.com (you may need to contact dreamhost support for this).
Then create a new subdomain (the control panel should allows you to do so) named wbb.multiwii.com and point it to a directory in your account. Then place a .htaccess with the code above in the root of the subdomain directory.

Post Reply