Cambiare Root Domino in Dinamico su WordPress

Di solito evito del tutto il problema ogni volta che creo un nuovo sito wordpress:

define('WP_HOME', '/');
define('WP_SITEURL', '/');

farà sì che wordpress utilizzi gli URL relativi alla radice per tutto. Semplifica notevolmente la migrazione del sito ad altri domini. Ofc, se accedi al tuo sito utilizzando una cartella (es. ” http://<domain>/blog “) potresti cambiarli in:

define('WP_HOME', '/blog/');
define('WP_SITEURL', '/blog/');

Per i siti esistenti, assicurati che il database e tutti i file di temi/plugin siano privi di URL assoluti generati da wordpress utilizzando i vecchi valori WP_HOME e WP_SITEURL.

Oppure questa è una alternativa, da inserire sempre in WP CONFIG.

/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/* THIS IS CUSTOM CODE CREATED AT ZEROFRACTAL TO MAKE SITE ACCESS DYNAMIC */
$currenthost = "http://".$_SERVER['HTTP_HOST'];
$currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME']));
$currentpath = preg_replace('/\/wp.+/','',$currentpath);
define('WP_HOME',$currenthost.$currentpath);
define('WP_SITEURL',$currenthost.$currentpath);
define('WP_CONTENT_URL', $currenthost.$currentpath.'/wp-content');
define('WP_PLUGIN_URL', $currenthost.$currentpath.'/wp-content/plugins');
define('DOMAIN_CURRENT_SITE', $currenthost.$currentpath );
@define('ADMIN_COOKIE_PATH', './');

Via