discuss.answer
-
- 571 Posts
I have encountered this problem as well. For portability I use the MODX tag
[[++site_url]] instead of hard coding the actual url.
[[++site_url]]ccc/site.css
-
- 1,154 Posts
Thanks Andy and good point, it does work, but why on earth is this possible. The mystery deepens haha.
Consider this structure, this is what I started with, I have pulled out unimportant stuff:
<!DOCTYPE html>
<head>
<title>[[*pagetitle]] | [[++site_name]]</title>
<base href="[[++site_url]]" />
<meta name="rating" content="General" >
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Custom CSS -->
<link rel="stylesheet" href="css/site_css.css" type="text/css">
I have told .htaccess to re-write all [[++site_url]] to https.
Now that second href should be built on the [[++site_url]] automatically, that's sort of what the base_url is for in the first place. Isnt that right?
When the href does its job its supposed to get the site url in order to finish that request. Or maybe I am way off base.
Anyway thanks again, its a better way than hard coding.
-
- 24,544 Posts
I would recommend this instead (with the exclamation point). It makes sure the site URL is always fresh and will prevent problems if you ever introduce more front-end contexts:
<base href="[[!++site_url]]" />
[ed. note: BobRay last edited this post 5 years, 10 months ago.]
-
- 571 Posts
Quote from: nuan88 at Jun 28, 2018, 01:32 PM
Now that second href should be built on the [[++site_url]] automatically, that's sort of what the base_url is for in the first place. Isnt that right?
When the href does its job its supposed to get the site url in order to finish that request. Or maybe I am way off base.
I agree. I felt I was bodging something that ought to have been working correctly with the code that I had.
Although interestingly I have just tested reverting my site to use
<link rel="stylesheet" href="assets/theme/css/site.css?version=3">, cleared the cache, and it is returning https as expected.
I do have
<base href="[[!++site_url]]" /> on my template as suggested by Bob, so perhaps that is what is making it work.
-
- 1,154 Posts
Thanks for the feedback Andy and BobRay.
The problem is an interesting one, because it seems to get a pass sometimes and only breaks things after some time. I don't know, sometimes I feel like I have caching problems, like I fixed something the other day and it wasn't fixed the next morning. Annoying.
But in this case I am 95% sure that bit of code had not been changed recently. It might be something like the browser getting more finicky.