Friends, help me figure it out. When you turn on the wordpress cache, the address of the type: mydomain.com/?p=123 turned into mydomain.com/Hello-World But this is not a problem, there are such links as:

 mydomain.com/Hello.-World mydomain.com/Hello-&-World 

when you enter them, the site gives an error. if you delete all extra characters like "." or "&", then everything is OK and the pages are loaded without any problems

for deletion, I used the following query:

 UPDATE `wp_posts` SET `post_name` = REPLACE( post_name, '.', '' ); UPDATE `wp_posts` SET `post_name` = REPLACE( post_name, '&', '' ); 

And here's the question: how to build a query so that all characters except for

БУКВ,ЦИФР и ТИРЕ (in one request at once)?

So as not to build 50 removal requests.

Thank.

  • one
    Unfortunately, MySQL does not know how to do replace by regexp . The easiest way, in my opinion, is to remove the dump of the database, delete the extra characters in it and reload it. Or delete characters with separate requests. - Pyramidhead
  • Thanks for the clarification, so do. - valextt

1 answer 1

 create procedure multiremove(charstodelete text) begin while length(charstodelete)>0 do begin set @onechar = substring(charstodelete,1,1); set charstodelete = substring(charstodelete,2,length(charstodelete)); set @sql=CONCAT("update wp_posts set post_name=replace(post_name,\'",@onechar,"\',\'\');"); prepare stmt from @sql; execute stmt; deallocate prepare stmt; set @sql=''; set @onechar=''; end; end while; end; 

On sql.ru - more.

If desired, you can refine and transfer the procedure name of the table and fields.