MadHatter Posted December 19, 2014 Share Posted December 19, 2014 Hi, I've tried printing the domain url but can't get ProcessWire to return anything. I can get it to work if I manually define the url in config.php but shouldn't this be detected automatically? Link to comment Share on other sites More sharing options...
adrian Posted December 19, 2014 Share Posted December 19, 2014 Any chance you are using these inside a function or module? In that case you'd need: wire('config')->urls->root Do you have debug mode turned on? That should let you know that you have an undefined variable: $config 2 1 Link to comment Share on other sites More sharing options...
MadHatter Posted December 19, 2014 Author Share Posted December 19, 2014 I'm just trying to echo it out in a template file. I'm just trying to get ProcessWire to print out the web address of the site (e.g. "http://www.example.com"). Link to comment Share on other sites More sharing options...
adrian Posted December 19, 2014 Share Posted December 19, 2014 Well: $config->urls->root will usually just give you "/" $config->httpHost should give www.example.com How are you defining the url in config.php ? Is this an issue in your local testing environment, or on a live server? Link to comment Share on other sites More sharing options...
MadHatter Posted December 19, 2014 Author Share Posted December 19, 2014 The domain is listed in the $config->httpHosts array. Does the domain need to be speicified for it to be callable via $config->urls? I was under the impression that it was pulled automagically from $_SERVER environment variables. Link to comment Share on other sites More sharing options...
adrian Posted December 19, 2014 Share Posted December 19, 2014 Sorry, in a rush, but I think you are correct - I think it's coming from: $_SERVER['HTTP_HOST'] https://github.com/ryancramerdesign/ProcessWire/blob/7b9730d43e6eda8bd27841a4811a1b9737bfe903/index.php#L41 I wonder if Ryan should add a backup check for $_SERVER['SERVER_NAME'] if host return nothing. Can you confirm what $_SERVER['HTTP_HOST'] is actually returning? Link to comment Share on other sites More sharing options...
MadHatter Posted December 22, 2014 Author Share Posted December 22, 2014 $_SERVER['HTTP_HOST'] is returning the web address I'm currently using. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now