Redirect Single Post CPT (Custom Post Type) to a specific URL

I have a domain and subdomain

At the scope, I created a custom post type called resources and a portfolio grid (using Elementor) to display it’s featured image with the title.

When clicking on the grid item, the single post is shown for example:

I’d like to remove the single post from the domain and redirect on click to I already have this page on the materialssubdomain).

How can I achieve that?

2 Answers

Sometimes this would be achievable with add_rewrite_url but it looks like in this case it’s not as you need to redirect to a different domain.

In this case you need .htaccess or nginx rules to do this, so you need to add something like this to your nginx config for only, in order to rewrite those URLs:

rewrite ^/resources/(.+)$1 permanent;

You’ll likely need to restart nginx after you add this to the config file.

Happy to help if this doesn’t do exactly what you want. There’s more examples of nginx rewrite rules here:

Leave a Comment