By greenbeans on
I have a page that gets read by a third-party payment processor, which then presents the resulting HTML to the user. It's currently breaking because all the links to CSS and javascript files in the <head> are site-root-relative instead of absolute. Is there any way I can force these links to be absolute?
Thanks!
Comments
I'm not sure I fully
I'm not sure I fully understand what the third party site is doing but one option may be to add/change the $base_url in /sites/default/settings.php to be the absolute path of your site.
Copied from settings.php:
/**
* Base URL (optional).
*
* If you are experiencing issues with different site domains,
* uncomment the Base URL statement below (remove the leading hash sign)
* and fill in the URL to your Drupal installation.
*
* You might also want to force users to use a given domain.
* See the .htaccess file for more information.
*
* Examples:
* $base_url = 'http://www.example.com';
* $base_url = 'http://www.example.com:8888';
* $base_url = 'http://www.example.com/drupal';
* $base_url = 'https://www.example.com:8888/drupal';
*
* It is not allowed to have a trailing slash; Drupal will add it
* for you.
*/
# $base_url = 'http://www.example.com'; // NO trailing slash!
Same problem
Hello,
I have the same problem than the poster (need absolute links instead of relative ones) and tried specifying the $base_url in the settings.php but this does not solve the issue, links are still relative.
FYI I need this because I got an external tool fetching one of the page to send a newsletter and all links in the mail end up being relative thus the mail is broken
Any other idea (beside asking the developers to fix their broken newsletter tool)?
Thx,
Claude
An improper way to accomplish
An improper way to accomplish absolute links would be to open up
includes/common.inc
scroll down to line 1413 (assuming you're using D6)
and set absolute to equal TRUE.
I'm also looking for a fix
I'm also looking for a fix here without hacking anything core.
I have the same problem
I have the same problem
look into the web_widgets module
Check out the method used by the web_widget module to change relative path links to full url links
from web_widget.module
maybe you could use a similar approach for the pages requested by the third party processor
or use settings.php's $base_url
There is also a setting in settings.php called $base_url, that allows you to force the base_path of your site into a specific url
That won't fix the css/js to
That won't fix the css/js to be absolute. Anyone found resolution how to?
Follow prind's suggestion
If you follow prind's suggestion above and set the $_GLOBAL['base_path'] variable to your site's base path, the javascript/css header URLS will output as absolute links rather than relative ones.