Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] Server Check if localhost


Go to End


2 Posts   1028 Views

Avatar
Graphicator

Community Member, 62 Posts

27 July 2011 at 1:09pm

I'm syncing across local computers over to my remote server. In light of Director::set_dev_servers, I would like to know if I can check if the status of where I am viewing the site.

If it is localhost, i'd like to run

require_once('conf/ConfigureFromEnv.php');

If it is on the server

$databaseConfig = array(...

Avatar
Graphicator

Community Member, 62 Posts

27 July 2011 at 1:24pm

Edited: 27/07/2011 1:26pm

define('current_domain', $_SERVER['HTTP_HOST']);

start of conditional statement
#### whatever port you are running your test server

if(current_domain == "localhost:####"): 

then include the localhost environment...

this allows me to safely sync and overwrite the complete mysite folder