Drupal base_url 错误地写入了额外的子域
我们在 RHEL (RedHat) 服务器上安装了基本的 drupal 多站点。 由于某种原因,在查看网站时,资产 URL (CSS/JS) 都指向错误的子域。
我们的网站 URL:http://drupal.sandbox.domain.com
drupal 索引页面加载的资产 URL 写为:http://drupal.sandbox.sandbox.domain。 com
。 为什么 drupal 会添加额外的 .sandbox
子域?
.htaccess
文件已保留为默认值,也尝试将 RewriteBase 设置为 /
,但没有任何更改。 sites/default/settings.php
文件的 base_url 设置为: $base_url = 'http://drupal.sandbox.domain.com'
但 Drupal 会覆盖此设置某处。将 $base_url
设置为服务器的 IP 会导致资产链接到正确的位置(使用 IP 而不是实际的域),但这并不理想。
我已经在 Ubuntu 服务器上使用相同的配置进行了测试,没有任何问题。我不确定如何确切地找出这个问题的原因。
编辑:服务器似乎正在解析域并立即覆盖包含 URL 字符串的变量。 例如:
$base_url = 'http://drupal.a.domain.com'
die($base_url); // shows: http://drupal.sandbox.a.domain.com
We have a basic drupal multi-site installation on a RHEL (RedHat) server.
For some reason when viewing the site, the asset URLs (CSS/JS) all point to the wrong subdomain.
Our site URL: http://drupal.sandbox.domain.com
the drupal index page loads up with asset URLs being written as: http://drupal.sandbox.sandbox.domain.com
.
Why would drupal add in the extra .sandbox
subdomain?
The .htaccess
file has been left as the default, also attempted to set RewriteBase to /
, but there was no change. The sites/default/settings.php
file has the base_url set to: $base_url = 'http://drupal.sandbox.domain.com'
but Drupal is overwriting this somewhere. Setting the $base_url
to the IP of the server causes the assets to be linked to the correct location (using the IP rather than the actual domain), but this is not ideal.
I've tested using the same configuration on an Ubuntu Server without any problems. I'm not sure exactly how to track down the cause of this problem.
EDIT: It seems that the server is resolving the domain and immediately overwrites the variable containing a string of the URL.
e.g.:
$base_url = 'http://drupal.a.domain.com'
die($base_url); // shows: http://drupal.sandbox.a.domain.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是 Drupal 特有的问题。通过创建独立的 PHP 页面并使用相同的代码进行测试,可以轻松检查这一点。由于该变量在设置后立即被覆盖,这表明 PHP/Apache 是进行覆盖的人。
Apache 可能会覆盖输入和输出。请参阅:什么会导致 PHP 变量被重写通过服务器?
This is not a Drupal-specific problem. This can easily be checked by creating a standalone PHP page and using the same code to test. Being that the variable is overwritten immediately after it is set shows that PHP/Apache is the one doing the overwriting.
It is possible for Apache to overwrite input and output. See: What would cause PHP variables to be rewritten by the server?