Redirects from external url inside posts doesn't work

Since my move from WP to Ghost, I have numerous blog posts that have urls in them I do not want linked back to the old blog, that’s still live, but set to private. I’d like to create redirects from my old external domain to my new internal post instead. Is that possible? I’m pretty sure it should work.

This is what I wanna do: /tag/-something/

But it does not work! I’ve tried basically everything, even regex, but it doesn’t work. Please help.

If the URL you want to redirect lives on an external domain then the request will go to that domain rather than your Ghost domain so it’s not possible to add a redirect on your Ghost site.

You’ll need to set up the redirect on your old Wordpress site/domain.

Ahh typical. But thanks for the info! I guess I have to manually update all the links then, because I just tried to re-import an updated json and it duplicated all the posts that I’ve already imported. Thanks again for the fast reply.

When I changed from WordPress to Ghost, I changed the domain, and site structure. My solution was to create a new server in Nginx as follows:

server {
    listen 80;
    listen [::]:80;

    server_name old_domain;
    return 301 https://old_domain$request_uri;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name old_domain;

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ssl_certificate /etc/ssl/certs/old_domain-cert.pem;
    ssl_certificate_key /etc/ssl/private/old_domain-key.pem;

    location / {
        proxy_intercept_errors on;
        error_page 400 500 404 /;

    rewrite ^/(blog/)?rss https://new_domain/rss/ permanent;
    rewrite ^/(blog/)?$ https://new_domain/$1 permanent;
    rewrite ^/(blog/)?guest-post-submissions https://new_domain/call-for-guest-bloggers/ permanent;       
    rewrite ^/(blog/)?form-submitted https://new_domain/contact-successful/ permanent;
    rewrite ^/(blog/)?privacy-policy.* https://new_domain/privacy-policy/ permanent;
    # ... and so on.

    client_max_body_size 50m;

However, if you were using a third-party host, i.e.,, this method won’t work since you need to point the domain to the server hosting Ghost.

1 Like

Thank you for that reply!
Yes, I’ve been using WP in various ways, both self-hosted and with and when I last moved my WP it was to without my domain. I’m just gonna have to take the time and change the domains manually, unless anybody knows a trick on how I can re-upload posts without creating duplicates that is…

1 Like

Is the site still active? If so, it may prove quicker to export the content to a local WordPress site, change the domain references, and then re-export for Ghost.

That was my plan. I shall try that!.

I did find this, and it works great - as long as it’s not regex. Any idea on how to use regex with a domain structure like this:

Doing it like this does not work, but it works in regex101:


Have you tried something like this?


I will try and get back to you tomorrow.

//Anna-Maria Eriksson

1 Like

It did not work, and when I tried again, I got an error and no way to fix it, something about null reading replace? I guess it doesn’t like that I tried to run the same code again or something.

UPDATE! It did work!
The issue was the ^ symbol at the beginning of the regex. When I removed it (and some of the extra back slashes, it worked! I have no idea why it suddenly stopped updating posts. Turns out it refused to update “old posts”, but new posts created with the add-random-posts.js file were fine, and with those I continued testing and found out this.

This was the working pattern:


Now I just hope it will work with my production site, without removing all the posts and importing them again.

1 Like