How to tweak your URLs without lost old references with Ghost

We basically need to rewrite every request to remove the date from our URL.

This is an example:

http://blog.zot24.com/2014/11/21/standardize-labels-between-github-repos/  

We want to remove this bit 2014/11/21 to make it look like:

http://blog.zot24.com/standardize-labels-between-github-repos/  

Without lost all the previous references to the old URL

First thing to do:

We need to rewrite every URL coming that contain a date, so:

We have this:

http://blog.zot24.com/2014/11/21/standardize-labels-between-github-repos/  

We want this:

http://blog.zot24.com/standardize-labels-between-github-repos/  

We need this to achieve that:

rewrite "\d{4}\/\d{2}\/\d{2}\/([^.]+)(.*)$" /$1$2 permanent;  

Change your configuration file:

I'm assuming you are using nginx

This is my configuration file:

/etc/nginx/sites-enabled/ghost

so I need to add the previous line like so:

...
location / {  
        ...

        rewrite "\d{4}\/\d{2}\/\d{2}\/([^.]+)(.*)$" /$1$2 permanent;
    }
...

Restart nginx

sudo service nginx restart  

Last thing to do:

We need to change the configuration of our Ghost to disable including the date into our URL's

And we're done :) all our old daties URL's are gone just clean and pretty ones.