Force %asset_url% keyword to return https: protocol?


#1

Matrix Version: 5.2

As the subject says, is it possible to force %asset_url% keyword to return https: protocol instead of http: ?

I know I can do a “force secure” option under “settings”, but manually doing it for 5000 pages is just not feasible for us.

Any help is very appreciated. Thanks.


(Peter McLeod) #2

Hi

You can set it in the site asset > URLs screen and uncheck the option for http. This will cascade to all children.

If you needed to allow a section within your to use a non https protocol then you could move it under another site asset, set the url to whatever the current url is (eg www.site.com/path/etc), then check the http option.

Thanks
Peter


#3

Great, Thanks Peter, We were thinking of using 301 redirects … but your solution is also an option now …


(Bart Banda) #4

You could do a keyword modifier with something like this:

%asset_url^replace:https:http%

Or alternatively just print the url without the protocol and hardcode the protocol:

https%asset_url^replace:.*\/\/://%

More tricks here: https://matrix.squiz.net/manuals/keyword-replacements/examples/useful-keyword-modifiers


(Bart Banda) #5

In 5.4 you can also use remap rules https://matrix.squiz.net/releases/5.4/5.4.0.0#remap-rules


#6

This looks like a great new feature Bart. Unfortunately, we are on 5.2 and recently set up thousands of indivisual remaps, which took a lot of effort and time.


(Chris Horikx) #7

Hi Bart,

How would you go about doing this with remap rules? I’ve given it a quick go with
|http://site/design/main.css| -> https://site/design/main.css
but it didn’t work (on _nocache)

Can the remap rules actually get at the protocol?


(Chris Horikx) #8

Actually, I’m working on a 5.4.1.3 system and I’m having troubles with the remap rules.

currently attempting:
|site.nsw.gov.au| -> www.site.nsw.gov.au

Should this remap redirect the request to the new URL and the URL display in the address bar? I can’t see any difference in the address bar when this rule is enabled and I attempt to visit site.nsw.gov.au.


(Bart Banda) #9

No they can’t. If you just want to redirect from HTTP to HTTPS for a site, it’s actually probably

best to just remove HTTP completely and let Matrix automatically redirect the user, you don’t need remap rules for that.

Do you have the “site.nsw.gov.au” URL also applied to your site asset? Because the remap rules will only redirect to new URLs if that URL doesn’t actually belong to an asset in the system already. In which case, you’d just need to remove that URL (domain) from the site asset and from all sub pages under that site.


(Chris Horikx) #10

Thanks Bart, yes, I will need to remove the no-dub domain to remap or just have the certificate apply to both. Thanks for your reply.

This an issue because of a weird thing happening with the ./?a= syntax. If I am in https protocol (https://www.site.nsw.gov.au) and the css is called (via nested content in a design area) using ./?a= it is defaulting to the HTTP url (http://www.site.nsw.gov.au/design/screen.css), not the HTTPS (https://www.site.nsw.gov.au/design/screen.css). Is this normal?

In a few weeks the site will have certificates applied throughout and can turn off HTTP but it is a bit dangerous to just turn off HTTP and hope for the best, it would be good if the ./?a= algorithm could continue the protocol so that HTTPS testing would be easier.


(Bart Banda) #11

No it’s not. This shouldn’t be happening, unless you are looking at a cached version of the nested standard page that has the link to the CSS file? (Try with /_nocache ?)

Also, make sure that the CSS file actually has a HTTPS url available on it as well.


(Chris Horikx) #12

Hi Bart,

All of your suggestions were already tested so have logged a support ticket.


(Bart Banda) #13

Ok no worries, let us know how it goes!