[wp-trac] [WordPress Trac] #44847: Redirect old date-based permalinks on structure changes
WordPress Trac
noreply at wordpress.org
Tue Jan 8 07:14:12 UTC 2019
#44847: Redirect old date-based permalinks on structure changes
------------------------------------------+------------------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Permalinks | Version:
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
------------------------------------------+------------------------------
Comment (by cleancoded):
First of all change the permalink structure from Word Press Dashboard, in
setting -> Permalinks change structure to post name.
Next step is redirect old URL structure to new structure from your server
configuration.
For Apache you can add these redirection rules in your .htaccess file.
{{{
RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$
http://%{HTTP_HOST}/$4 [L,R=301]
}}}
Now the next thing is to change the links saved in your database.
As we know Word Press save data arrays as serialized string as
{{{
a:3:{s:4:"home";s:42:"https://www.example.com/2018/12/04/my-
post";s:4:"link";}
}}}
It is very complicated to update these links manually.
You can use a PHP Script for search and replace word press databases. You
can download it from [https://interconnectit.com/products/search-and-
replace-for-wordpress-databases/ here].
Follow the instructions and install it in a separate directory that’s a
peer to wp-admin and wp-content.
I gave the directory a name like srDB_201812. Then you just go to
http://example.com/srDB_201812/index.php and you’ll see a nice admin
interface.
Enter your regular expression for search, what you want to replace it
with, and enter your database credentials.
Perform the live run and you’re done.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/44847#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list