Reputation: 362
I am running a Wordpress 4.1 instance off of an Apache 2.2 server. All of my wordpress files are in a /var/www/html/wordpress
directory, so I can access them at http://www.myurl.com/wordpress.
Wordpress is also connected to a remote database on a different server. My wp-config.php
file has the following:
define('DB_NAME', 'my_db_name');
define('DB_USER', 'my_db_user');
define('DB_PASSWORD', 'my_db_password');
define('DB_HOST', 'db.dbhost.com');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
Most of the site works fine, but if I look at some paginated data (for example, the users table), then when I click to go to the next page it creates a link using the DB_HOST instead of my site URL.
For example, trying to access the second page of users creates the URL http://db.dbhost.com/wordpress/wp-admin/users.php?paged=2 rather than http://myurl.com/wordpress/wp-admin/users.php?paged=2. If I manually type in the second link, the page appears as expected.
How can I fix this?
Upvotes: 0
Views: 7210
Reputation: 362
I have found the answer to this. The problem was my proxy, and the solution was to add the following to my wp-config.php
file:
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
$_SERVER['REQUEST_URI'] = str_replace("wordpress", "home",
$_SERVER['REQUEST_URI']);
Solution found here: https://wordpress.org/support/topic/wordpress-behind-reverse-proxy-1
Upvotes: 1
Reputation: 6305
You can override the values set in the options table by adding this to wp-config.php
:
define('WP_HOME','http://www.example.com/wordpress');
define('WP_SITEURL','http://www.example.com/wordpress');
I prefer doing it this my for my projects because I can set different values for development, staging and production environments without having to mess with the database.
Upvotes: 2