Hi everyone,
I have a big issue actually, as i don’t want to modify URLs of each download 1 by 1 after changing my server (new domain name)
I tryied editing the database and replace each http://…. by the new one using notepad++ but when importing the database, all fields in attached files get empty.
Is anyone have an idea how to massively replace a part of the attached files URLs after changing server?
Thank you very much.
Any moderator available to answer? i searched the addon list without finding anything usefull
Sorry, not clear, download URLs are not static, they are dynamically generated and if you move content to another domain , link automatically use the new domain.
I mean each time you add a package, for the attached file, I add an URL for the file to download (on an external server, i don’t use the “upload” function), this URL is set by me.
now all my packages have a URL http://ns32……… but i’m moving all my files to a server named http://ns42….. (still an external server, not the one where WordPress is set)
so all my downloads will not work, i can actually go inside each packages 1 by 1 to update the link to the new server, but doing than more than 3000 times is not what i want.
I tryied to modify those packages link directly into the database, but when i do that, when i edit a package, attached file URL is empty.
What are my solutions?
Hope there is lol, would be hell annoying to update each package. Still trying to find a solution
I see, it will require to write some code, you may try using:
global $wpdb; $data = $wpdb->get_results( "select * from {$wpdb->prefix}postmeta where mey_key='__wpdm_files'" ); foreach($data as $d){ $newurl = array(); $oldurl = maybe_unserialize($d->meta_value); foreach($oldurl as $id โบ $url){ $newurl[$id] = str_replace("ns32", "ns42",$url); } update_post_meta($d->post_id, '__wpdm_files', $newurl); }
Thanks, will try that and keep you posted ๐
Hello there,
I am in the same situation. Does the proposed code worked for you @Renzukoken ??
Thanks!
Hi, I actually managed to un-hack my server so didn’t had to use this script yet (i kept it on a safe place to try as soon as i change server)
But i’ll be very happy to hear about it if someone tries it ^^
I am not hacked but I am in the process to move from a shared hosting to a VPS one. So all of my internal paths of my files should be changed!
I will keep you updated of how will go ๐
My first try was to just do an UPDATE through the phpmyadmin, with a total failure. Then I realize that the data ara actually serialized…
awsome news ๐ you just copy past the code into the SQL request of phpmyadmin? or just in a PHP script you run from your webpage
It is a PHP code. Not SQL. I just created a page template with the code inside and run it once!
thanks a lot
Hi
Sorry to open this old topic, but now changing to a soyoustart server, i decided to follow the steps from this topic to change the files path
From the previous comments look like it woks well, badly, got no clue where to put this code, can anyone guide me for this part?
just tried by copying paste on a template page without result :
Thanks ๐
PS : Can’t it be replaced by an SQL request to do the same thing?
You can not use plain SQL request because the data are serialized!
Just create an empty Page Template, put the code in with the correct modifications for your case. Then create a Test Page using the Page Template you created just before. And run this page ONCE!
You can add some “echo”s just to debug it.
Found the issue ๐
It was a simple mistake, there is mey_key in the script, a T is missing : meta_key
In the end i created a simple php file at the root of the serveur with inside
include_once('wp-load.php' );
mysql connect etc...
then the script with the missing letter T
And all works perfectly ^^ thanks
The topic ‘Changing files URL's in mass’ is closed to new replies.