0

I am working with a Drupal site that is a central hub for several other pieces of software. The Drupal site and the other Software all have their own dev, testing and production environments. Each of these environments have their own url.

What I am looking to do is to change these urls based on the current envrionment by setting a variable/token of some kind. For example:

  • If the site is in dev, it links to all other dev versions of the software. For example dev-drupal.website.com links to dev-software1.website.com and dev-software2.website.com
  • If the codebase moves to testing, there is a file (for example the template.php) file that either doesn't need to be changed, or needs to be changed once to change all of the links.

There are over a dozens of these externally linking software pieces, and they are often linked in the content, but there are also menu items, blocks and a few views. Currently we have to do a find and replace to manually change these links one at a time. I'm trying to figure out if there is a better way, perhaps through a template variable or a token. Any ideas? This solution would ideally not be stored in the db, but I'm flexible.

I'm looking for suggestions on the best approach.

2 Answers 2

0

I don't think I would try to do this in Drupal. I would setup a small proxy server using Apache/mod_rewrite. You can rewrite your url's based on the source url. There is some good starter information at on the Apache doc site. There is also full on mod_proxy, but I think mod_rewrite would be sufficient for your use case.

0

At best, you should set the $base_url in settings.php per environment and use relative links everywhere. A module like Pathologic will also help here. The last thing you want is to use links with the domain in them that get saved to the database - with relative links, you'll be gold.

You can determine environment from settings.php a few ways, either by ENV variable or server IP. You could also supply a folder per site to utilize multiple settings.php files. Drupal will use the domain folder it finds under sites/.

You may also be interested in looking at hook_url_outbound_alter.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.