Query on redirects.yaml file

I am wondering if it’s okay to have 10,000 entries in the redirects.yaml file?

we are in the middle of migration and need to redirect the content published earlier.

It’s not really the intended usage but it may work, you’d need to test on your specific hardware to see whether performance is acceptable for your use case.

However, you’ll likely get much better performance by implementing the redirects at the web server level (nginx/apache/etc) rather than the Ghost application level.

1 Like

When I migrated from WP to Ghost I created the redirects in Nginx (a separate server block), which provided the benefit of more complex regex expressions, and reduced the number of redirects considerably.

That’ll probably help. Can you guide me to a few resources which I can be of help regd this @mjw

I can point you in the right direction, but first, you’ll need to explain a little more about the redirects. For example, are you changing the bare domain in any way, moving to a sub folder etc.

The server block may take this approach.

server {
          ...
          location = /blog
          { 
            rewrite ^/blog/?post-name$ /post-name permanent;
          }
          ...
}

Or simply rewrite ^/(blog/)?post-name /post-name permanent; if a post optionally sits in a sub folder. What you do depends on the redirects, and how you handle rewrites using regex.

Note that the permanent flag should not be used until you’re satisfied redirection is working correctly.

An optional flag parameter can be one of:

last
stops processing the current set of ngx_http_rewrite_module directives and starts a search for a new location matching the changed URI;
break
stops processing the current set of ngx_http_rewrite_module directives as with the break directive;
redirect
returns a temporary redirect with the 302 code; used if a replacement string does not start with “http://”, “https://”, or “$scheme”;
permanent
returns a permanent redirect with the 301 code.

1 Like