Wordpress Permalink Change - NGINX Rewrite Wanted

I have changed my Wordpress permalink structure from:

/%year%/%monthnum%/%day%/%postname%/

TO

/%postname%/

But i'm not sure what to put in my nginx config file for the old links to be re-directed to the new ones. Heres a copy of my existing file:

server {
            listen   80;
            server_name  www.servinghomeserver.com;
            rewrite ^/(.*) http://servinghomeserver.com/$1 permanent;
       }

server {
            listen   80;
            server_name servinghomeserver.com;
            access_log /home/public_html/servinghomeserver.com/log/access.log;
            error_log /home/public_html/servinghomeserver.com/log/error.log;

            location /  {
                        root   /home/public_html/servinghomeserver.com/public/;
                        index  index.php index.html;                      
                        }

            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$ 
                        {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include /usr/local/nginx/conf/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /home/public_html/waywiderweb.com/public/$fastcgi_script_name;
                        }
       }

I want to keep the existing code in there where www requests go straight to http - Please help and thanks in advance.

6 Replies

Or just use this plugin:

http://scott.yang.id.au/code/permalink-redirect/

After installing it, in Settings -> Permalink Redirect, under "Old Permalink Structures", put

/%year%/%monthnum%/%day%/%postname%/

in there. "Update Options" and you are set. It basically catches any 404 and then tries to compare whether it matches any old permalink structure and then redirect you to the new URL.

Disclaimer: yup I wrote that WP plugin.

Thanks Scotty - So is this ok for SEO purposes it passes a 301 redirect I persume?

G'Day PTC,

I got this one going by following guvnr's guide here.

Thanks Moses - I have followed the guide (excellent, I must say), but the Guvnr's guide only covers having permalinks enabled NOT directing old format to new (e.g. /%year%/%monthnum%/%day%/%postname%/ to /%postname%/ ) as a 301 redirect thats ok for SEO purposes. Thats why i wondered if the Permalink Redirect plugin Scotty mentioned was ok for SEO purposes? :?:

@PhillTheChill:

So is this ok for SEO purposes it passes a 301 redirect I persume?

Yup. That's the whole point. It has been tested under Apache and Nginx and should throw 301 to redirect the clients to the new permalink.

Thanks Scotty. One other thing can you update your plugin so I can redirect feedburner to using feedburner with my own domain eg. http://feeds.mswhs.com/mswhs

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct