Welcome! Log In Create A New Profile

Advanced

Redirects after change permalinks on WordPress

Posted by gilvancn 
Redirects after change permalinks on WordPress
September 01, 2016 10:48AM
Hello guys, I have an old site in WordPress using Nginx configured by EasyEngine script. Permanent links include the year and month of posting the url besides the category, as in the example below:
example.com/2012/01/category-name/title-post

The problem is that I want to update those posts and repost the current date. By doing so the URL will change to:
example.com/2016/08/category-name/title-post

To avoid all this trouble, I will change the permalinks in WordPress settings for:
example.com/title-post

Now the question: Is there any way to redirect all the old traffic of:
example.com/2012/01/category-name/title-post
To: example.com/title-post
Not to lose the links and gives 404?

From what I've been reading, you can do this redirection using regular expression, the more I have no idea how to do this using nginx.

I would like to do this redirect without the need to plug and without manually place line by line for each post, because my site has thousands of posts.

The following code in .htaccess makes this magic in apache:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+)/([^/]+)/$ http://example.com/$4

I am not able to convert it to nginx. Some guys idea?




TRADUZIDO DE:
Olá rapazes, Tenho um site antigo em WordPress usando Nginx configurado pelo script EasyEngine. Os links permanentes incluem o ano e mês da postagem na url além da categoria, como no exemplo abaixo:
example.com/2012/01/category-name/title-post
O problema é que quero atualizar esses posts e repostar na data atual. Fazendo isso a url mudará para:
example.com/2016/08/category-name/title-post
Para evitar todo esse problema, vou mudar os links permanentes nas configurações do WordPress para:
example.com/title-post
Agora a pergunta: Tem alguma forma de redirecionar todo o trafego antigo de:
example.com/2012/01/category-name/title-post
Para: example.com/title-post
Para não perder os links e dá erro 404?
Pelo que andei lendo, talvez consiga fazer esse redirecionamento usando expressão regular, mais não tenho a menor noção de como fazer isso usando nginx.
Gostaria de fazer esse redirect sem a necessidade de plugin e sem colocar manualmente linha por linha para cada post, devido meu site ter milhares de posts.
O seguinte código no .htaccess faz essa mágica no apache:
CODIGO
Não estou conseguindo converter isso para nginx. Alguma ideia rapazes?



Edited 1 time(s). Last edit at 09/01/2016 10:53AM by gilvancn.
Re: Redirects after change permalinks on WordPress
October 14, 2016 06:24AM
Same problem, I need to do a redirect 301 to new permalink structure.
On Apache this rule works: RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://www.site.com/$3

What's the rule on Nginx?
Re: Redirects after change permalinks on WordPress
October 14, 2016 06:40AM
I found this: http://www.markomedia.com.au/wordpress-nginx-permalinks-rewrite/
Re: Redirects after change permalinks on WordPress
October 14, 2016 07:54AM
Thanks @Artie55



Edited 1 time(s). Last edit at 10/14/2016 07:54AM by gilvancn.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 100
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready