301 redirect to my old forum archive

(Tudor Vedeanu) #1

My current website (let’s call it site.com) has a Wordpress install in the root and a forum at site.com/forum. What I want to do is:

I’ll probably use two separate droplets on Digital Ocean for this setup.

The question is: how do I do some 301 redirects to my old website? Like this:
site.com/forum/whatever :arrow_right: archive.site.com/forum/whatever.


Redirect old URLs
(Sam Saffron) #2

@neil is our magic redirect documented somewhere ?

(Neil Lalonde) #3

Hmm… our magic permalinks table currently doesn’t have a way to redirect away from the site. It maps an incoming url to a topic_id, category_id, or post_id. It’s was originally meant to handle redirects into Discourse from an old forum, not the other way around.

I can add another column to support that.

(Tudor Vedeanu) #4

So currently there is no way to do this using some Nginx magic?

(Michael Downey) #5

Since the web server sits in front of Discourse, you should be able to do HTTP 30x redirects before Discourse even processes the request. See https://jeffsebring.com/2012/nginx-301-redirects/ for some ideas, or Google around for other techniques.

(Tudor Vedeanu) #6

Could you give me more details about this? Where exactly should I add the redirect directives?

I followed this tutorial:

and I added a server {} block containing the redirect code inside app.yml, hoping it’ll work, but it didn’t.

(Kane York) #7

I think you add another location block.

(Tudor Vedeanu) #8

Obviously I’m a newbie so if anyone could tell me exactly what I should add and where, I’d appreciate it. Whatever I’ve tried so far it didn’t work.

(Neil Lalonde) #9

I added a newbie-friendly way to setup the redirects, and wrote a howto post about it. Since you want everything that matches /forum/* to redirect, it’s probably not the best solution. The nginx approach is best.

(Benjamin Kampmann) #10

Have you seen Converting rewrite rules ?

I assume the following in the Nginx-Conf should do it:

server {
        rewrite  (/forum/.*)  http://archive.site.com$1;

Be aware that to it is my understanding that the config is rewritten eveytime you reconstruct the discourse-docker container.

(Tudor Vedeanu) #11

I tried that and other similar rules but maybe I did something wrong each time, or maybe the Nginx/Discourse combination ignores them. In any case it didn’t work.