wesleytodd / YeoPress

A Yeoman generator for WordPress
Other
1.08k stars 163 forks source link

Unable to change wordpress site address (URL) #178

Closed jshih-webmaster closed 8 years ago

jshih-webmaster commented 8 years ago

I want to update my initial installed site url (http://yeopress.localhost) to (http://localhost/yeopress)

I've updated all my in original site url in the database to the new url. However in the admin 'general settings', you can still see both 'Wordpress Address (URL)' and 'Site Address (URL)' shows the old original URL. I'm unable to change them inside the admin 'general settings' because they are disabled (grey out).

Do you know how I can change it?

Toddses commented 8 years ago

Did you install WordPress in a subdirectory? Take a look at your wp-config.php and look for the section that sets custom paths. It looks like this probably:

/**
 * Set custom paths
 *
 * These are required because wordpress is installed in a subdirectory.
 */
if (!defined('WP_SITEURL')) {
    define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress');
}
if (!defined('WP_HOME')) {
    define('WP_HOME',    'http://' . $_SERVER['SERVER_NAME'] . '');
}
if (!defined('WP_CONTENT_DIR')) {
    define('WP_CONTENT_DIR', dirname(__FILE__) . '/content');
}
if (!defined('WP_CONTENT_URL')) {
    define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/content');
}
jshih-webmaster commented 8 years ago

Yup, I did install WordPress in a subdirectory. The custom paths in the wp-config.php has the same configuration as above. But where can I change the WP_SITEURL and WP_HOME ?

Toddses commented 8 years ago

@jshih-webmaster You will need to change it in your wp-config.php. Since it is defined here, it will essentially ignore whatever is set in the database and dynamically set the URLs using the schema in wp-config.

For a subdirectory install, the code above should look like this:

/**
 * Set custom paths
 *
 * These are required because wordpress is installed in a subdirectory.
 */
if (!defined('WP_SITEURL')) {
    define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/DIRECTORY/wordpress');
}
if (!defined('WP_HOME')) {
    define('WP_HOME',    'http://' . $_SERVER['SERVER_NAME'] . '/DIRECTORY');
}
if (!defined('WP_CONTENT_DIR')) {
    define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/DIRECTORY/content');
}
if (!defined('WP_CONTENT_URL')) {
    define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/DIRECTORY/content');
}

DIRECTORY should be your subdirectory where your site is installed. So for your case it would be yeopress. Also note the change to dirname(__FILE__). For subdir install it should be $_SERVER['DOCUMENT_ROOT'].

You may also need to change the references to wordpress and content, depending on what you have named those two directories.

Let us know if those changes take care of it for you.

jshih-webmaster commented 8 years ago

Thanks Toddses! That solved my problem.

Toddses commented 8 years ago

Great news!