1

Would appreciate any assistance of how to handle configurable URLs for each environment.

The links need to take the user to a different URL depending on the environment the site is installed in. In test environment, they would go to the test site, in beta test environment, beta site. And in production, production.

Currently I am calling the test url by h ref in the body text. However, when the site is moved to beta, I would have to manually change the url to the beta url and so forth. I have about 50 of these type of URLs throughout my site so I am looking for a automated way.

I have thought about using

https://www.drupal.org/project/scanner https://www.drupal.org/node/257026#example-use-cases

But open to any suggestions or experience.

Many thanks in advance!

Mike

4
  • print $base_url . 'rest/of/url/here'; I believe $base_url should change automatically assuming you never changed it in settings.php
    – blu
    Commented Dec 1, 2016 at 18:58
  • even if my domain name for each environment is different?
    – mike
    Commented Dec 1, 2016 at 19:18
  • i believe so, although it may default to /. Anyways it might be better to use something from here: link I would try $_SERVER['SERVER_NAME'] or $_SERVER['SERVER_ADDR'] in a switch statement
    – blu
    Commented Dec 1, 2016 at 19:53
  • If I understand your use-case properly, as far as I know everybody uses Pathalogic for this.
    – mona lisa
    Commented Dec 2, 2016 at 0:12

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.