Wordpress Permalink Change - Rewrite Wanted

merlin corey merlincorey at dc949.org
Wed Jan 13 03:11:05 MSK 2010


On Mon, Jan 11, 2010 at 12:13 PM, Philip Churchill
<philip at churchilluk.co.uk> wrote:
> 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.

# Nginx side, but would recommend the wordpress plugin instead!
location ~ ^/(.*)/(.*)/(.*)/(.*)/$ {
  rewrite ^ /$4 permanent;
}

On Mon, Jan 11, 2010 at 2:41 PM, Ross <ross at thegodlikehobo.org> wrote:
> The following will make Wordpress permalinks work properly, assuming
> it is installed in the webroot.
>
> location / {
> try_files $uri $uri/ /index.php?q=$uri;
> }

Please check out http://wiki.nginx.org/Wordpress for more strategies.

> As for removing the www, you could use something like:
>
> server {
> listen   80;
> server_name  www.domain.tld;
> rewrite ^/(.*) http://domain.tld/$1 permanent;
> }

A better rewrite is:
rewrite ^ http://domain.tld$request_uri permanent;

-- Merlin



More information about the nginx mailing list