Wordpress Permalink Change - NGINX Rewrite Wanted
/%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
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.
@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.