Page rules with wordpress permalinks

Hi there! I am not quite sure how these page links work. I want

Home - HostUp(date here)/*
to redirect to:
https://hostup.org/blog/$1

so for an example.
/blog/2019/02/02/how-to-secure-a-ubuntu-linux-server-in-3-simple-steps/
redirects to
/blog/how-to-secure-a-ubuntu-linux-server-in-3-simple-steps/

How can I make it remove the date?

You can try the following but I wouldnt be surprised if it didnt work

hostup.org/blog/*/*/*/*

If that doesnt work you would probably have to look into workers. Iā€™d suggest doing it server-side though.

Yeah this is what I tried at first but it did not work :confused:

I guess I could always try something like this on the nginx server

RedirectMatch 301 ^/blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/]+)/$ https://hostup.org/$4

I just tried it with a demo page rule and it should actually work. Post a screenshot of your page rule.

In that case you will take the year. You want to refer to the fourth asterisk which is $4 then.

1 Like

Woops

Okay I changed it. Although it might take some time to update

https://hostup.org/blog/2019/02/02/how-to-secure-a-ubuntu-linux-server-in-3-simple-steps/ NOPE
https://hostup.org/blog/2019/02/02/how-to-secure-a-ubuntu-linux-server-in-3-simple-steps works :smiley:

That is probably because of the trailing slash. You might need another page rule but I cant guarantee that you will get this to work. Server-side is probably still the best choice.

2 Likes

rewrite ā€œ/blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)ā€ https://hostup.org/blog/$5 permanent; from - Why you should change your WordPress permalink structure ā€¢ Yoast I believe this will work for nginx rewrite. I will just try this instead when I get home :smiley: Thank you for the help anyways!

You can try Redirection, an excellent free plugin with which you can set your regular expression redirects. It allows you to write redirects to your .htaccess file.

The formula /*/*/*/*/, even if it worked with or without the trailing slash, could be problematic, as WordPress generates all kinds of archive and paginated pages that might result in something like:

example.com/category/category-name/page/3/ being redirected to
example.com/3/ and that would be a 404!

1 Like

This topic was automatically closed after 31 days. New replies are no longer allowed.