I am trying to use this project on GitHub https://github.com/ErisDS/Migrate to migrate the URL settings in my WordPress database from a Localhost dev install to a live URL.
At the moment the code throws an error for the URL to be replaced “http://localhost/mysitename”, but does accept the new URL “http://www.mywebsitename.com”
From what I can tell the error comes from this regular expression not validating the localhost as a valid URL – any ideas how i can update this to accept the localhost URL?
The full code can be viewed on GitHub.
function checkURL($url)
{
$url_regex = '/^(http\:\/\/[a-zA-Z0-9_\-]+(?:\.[a-zA-Z0-9_\-]+)*\.[a-zA-Z]{2,4}(?:\/[a-zA-Z0-9_]+)*(?:\/[a-zA-Z0-9_]+\.[a-zA-Z]{2,4}(?:\?[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)?)?(?:\&[a-zA-Z0-9_]+\=[a-zA-Z0-9_]+)*)$/';
if($url == 'http://')
{
return false;
}
return preg_match($url_regex, $url);
}
The Author of the MIGRATE scripts has updated the project on GitHub to include this fix. thanks for your help guys.
https://github.com/ErisDS/Migrate