I have a client who says that he is unable to view his company's website from inside his company's building. Their network engineers have asked to make sure that DOMAIN.COM is not included in any of the URLs generated by Drupal.

They want only relative paths everywhere in the code. Any insights?

  • 1
    Modifying how Drupal and contrib modules generate URLs hardly would be practical, therefore this question probably has to do more with servers and such, and is off topic here. – Kari Kääriäinen Mar 7 '14 at 22:22

You can alter all Drupal generated URLs to make them root relative using hook_file_url_alter

function mymodule_file_url_alter(&$uri) {
  global $base_path;

  $scheme = file_uri_scheme($uri);

  if (!$scheme || $scheme == 'public') {
    if (!$scheme) {
      $path = $uri;
    else {
      $wrapper = file_stream_wrapper_get_instance_by_scheme($scheme);
      $path = $wrapper->getDirectoryPath() . '/' . file_uri_target($uri);

    // Clean up Windows paths.
    $path = str_replace('\\', '/', $path);

    $uri = $base_path . ltrim($path, '/');

For links in content you can apply the filter supplied by Pathologic

| improve this answer | |

Dan, I believe this can be achieved within apache and the .htaccess file under mod rewrite. http://httpd.apache.org/docs/2.0/rewrite/rewrite_guide.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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