Open patrickatwsrn opened 2 months ago
I saw the same behavior once for 2.8.x, hard-coding solved the issue
I have the same behavior on a specific site on a specific hosting server. After clearing the MODX cache everything ist good again for a few month. Then suddenly it appears again.
Because this happens only on this server - I think it has to to with the hosting environment.
Like explained in the first link you posted, by default site_url
is set for every request based on the request itself (in the file core/config/config.inc.php
by using $_SERVER['HTTP_HOST']
, $_SERVER['HTTPS']
, etc.).
For example:
http://127.0.0.1/mypage.html
, [[!++site_url]]
is http://127.0.0.1/
http://localhost/mypage.html
, [[!++site_url]]
is http://localhost/
If site_url
is always used uncached (e.g. [[!++site_url]]
), this shouldn't create any issues.
If site_url
is used cached (e.g. [[++site_url]]
), this can create issues, because the first request (after the cache is cleared) defines the value of site_url
(in the cached file) for all future requests (until the cache is cleared again).
To avoid the problem, use site_url
always uncached.
Or you can create site_url
/http_host
context-settings/system-settings (to overwrite the generated values (from the request) in config.inc.php
).
Or maybe you can change the .htaccess
file to make sure that your site is always accessed with the same %{HTTP_HOST}
value.
Bug report
Summary
Quick summary what's this issue about.
Today some image links returned a path that included the ipv6 address instead of the domain name.
returns
instead of
This happens occationally (2-3 times per year) on other pages and I always "fix" it by hard-wiring the domain name into my tag.
I can also remember this problem to be popping up on acnchor links inside chunks using the scheme modifier.
Step to reproduce
It just happens, clearing the site cache solves the problem.
This seems to be a very old problem that occationally pops up:
(2011) https://forums.modx.com/thread/13720/site-url-returns-ip-address (2022) https://community.modx.com/t/links-randomly-changing-to-ip-address/5493
Observed behavior
n.a.
Expected behavior
In a single context environment, site_url should always return the domain name. In a multi-contecxt environment site_url should return the site_url of the current context.
Environment
MODX 2.8.6, PLESK Server running Ubuntu