I need advice regarding massive 301 redirects

Hola! after searching in the Meta and Google I’m not sure what’s the best way to proceed.

Background

I have a community with 15,8k topics, 967k posts, tons of images linked to S3. The forum is running under a subdomain (xxx.domain.com), and this yeah I want to migrate it to the root domain (domain.com)

Where am I lost?

I’m not an SEO expert, but as far as I know, the best way is forcing the 301 redirections, so that Google understands the change and it doesn’t affect to the positioning nor PageRank.

I know how to do this kind of redirection in custom websites or CMS like WordPress, but I’m not sure how to address this massive redirection with Discourse.

Is there something like best practices with Discourse?

Thanks, and sorry for the hassle.

2 Likes

I don’t think there is anything specific to Discourse.

When I do this I normally use a single line in .htaccess or similar:

Redirect 301 / https://example.org
2 Likes

I’ve achieved this with a plugin for a site migrated from wordpress. As Wordpress uses slugs in the url which are almost similar to discourse slugs, I’ve created such a rule via the plugin.
https://github.com/paviliondev/discourse-articles

It redirects url.com/slugurl.com/t/slug

3 Likes

Thanks for you answer: how are you using .htaccess exactly? as far as I know Discourse is not running Apache :thinking:

The easiest approach here is to configure a webserver on xxx.domain.com to 301 Redirect all requests to domain.com

For example:

but adapted to something like:

server {
	server_name xxx.domain.com;
	
	return 301 https://domain.com$request_uri;
}
2 Likes

I’m not an SEO expert either, but it seems like you’re asking for trouble. Have a look at Why use www? | www. is not deprecated, for example.

1 Like

Where is the file where I put the redirect commands. I can’t find nginx anywhere on my Docker-based Discourse installation.