I have a weird clash of names for a Wordpress installation, and I need to write a couple of Nginx rules to fix it.
I used to have my software projects listed in the Wordpress page /projects, with links to sub-pages /projects/aprojectname, /projects/anothername, etc.
Recently, I bought a theme with a custom post type for portfolio items. It is called project (note the missing s).
At /project, I access the default Wordpress listing of all the project posts. Then, I can access the posts using /project/aprojectname, /project/anothername, etc.
So far, so good. The issue is that I would like to use the new /project structure preserving any previous link to my /projects/something. Also, I would like to keep the /projects page only (no redirect).
This is what I would like to accomplish.
The URL /project only should redirect to /projects, so that I can show a Wordpress page instead of the "ugly" Wordpress listing of posts.
Consequently, The URL /projects only should not be processed. It should display the corresponding Wordpress page.
However, all URLs in the form /projects/something should redirect to /project/something
This is my nginx rule so far.
location ~ ^/projects/(.*) {
return 301 http://$server_name/project/$1;
}
This works good for 3.: /projects/aprojectname -> /project/aprojectname.
It does not work for 2., because it rewrites /projects to /project
I have no clue how to implement 1., as any attempt will affect the previously written rule.