Redirect pages with .html suffix to without html - Wordpress to Ghost Migration

We migrated our CMS from Wordpress to Ghost. However, Google has crawled our blogs with .html suffix when we were hosted on Wordpress.

After migrating to Ghost, the .html suffix was removed. Now we want to redirect all crawled .html suffix pages to without html

For example -
https://www.truworthwellness.com/blog/covid-19-workplace-vaccination-program.html to be redirected to https://www.truworthwellness.com/blog/covid-19-workplace-vaccination-program/

Add this to you nginx config.

location / {
    if ($request_uri ~ ^/(.*)\.html$) {
        return 302 /$1;
    }
    try_files $uri $uri.html $uri/ =404;
}

Once you’re satisfied, you can make the redirection permanent with a 301.

Thank you so much for this. Is it possible to implement this using Ghost redirects?

Update on this –

This was resolved using the below rule in redirects.json file

[{"from":"^/(.*)\\.html/?$","to":"/$1/","permanent":true}]
2 Likes