jpganz18
jpganz18

Reputation: 5858

is there any way to auto configure the base/home url on wordpress?

I was wondering if there is any way to do this without reconfiguring everything , database o wp-admin WP_HOME and WP_SITEURL and instead of that let Wordpress to recognize the IP is comming from and answer?

Example:

If i set on my wp_home and siteurl some IP (behind a balancer) or I set localhost/ and I access my site from outside (example, a domain or another computer on the local network that connects throught the local network IP), no css will be loaded (because will call for localhost...../styles.css

Is there any way to auto configure this and let it "dinamic" without have to change it all time?

Upvotes: 1

Views: 241

Answers (1)

FiLeVeR10
FiLeVeR10

Reputation: 2165

You can override the settings in wp-config.php

define('WP_HOME','http://'.$_SERVER['HTTP_HOST'].'/path/to/wordpress');
define('WP_SITEURL','http://'.$_SERVER['HTTP_HOST'].'/path/to/wordpress');

or

define('WP_HOME','http://'.$_SERVER['HTTP_HOST']);
define('WP_SITEURL','http://'.$_SERVER['HTTP_HOST']);

if it's always being served from domain root.

You can read more about it here.

Upvotes: 2

Related Questions