Hi,
I decided to go for a cleaner approach to redirects and simply output the links to the correct URLs the first time (wherever possible - there may be corner cases where it doesn't work).
This greatly helps when using Boost, as it means that there's less reliance on bootstrapping Drupal to get users on the right protocol. We had a problem that when a user finishes checking out their cart, they get sent back to the site on HTTPS, but anonymous users at that point start getting Boost pages again, so remain on HTTPS even though they should've switched back.
To activate this support you need to have the url_alter module installed, which defines hook_url_alter_oubound(), a hook backported from D7. When this module isn't installed, this functionality won't work (until D7), but it won't break anything.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | securepages.code_.893840-17.patch | 2 KB | gordon |
| #16 | securepages-url_outbound_alter-893840-16.patch | 1.22 KB | rooby |
| #8 | 893840-6-securepages.urlalter.patch | 1.18 KB | halcyonCorsair |
| #5 | 893840-5-securepages.urlalter.patch | 1.43 KB | neilnz |
| #4 | 893840-4-securepages.urlalter.patch | 1.93 KB | neilnz |
Comments
Comment #1
sillygwailoDoes this patch account for
<front>? If I don't have<front>in the list of pages to secure, then $path resolves to FALSE (empty) in the second if statement, and doesn't get rewritten withouthttps://.Comment #2
neilnz commentedIt doesn't do any specific checking, no.
On my site I don't have
<front>listed as a secure page, and my patch is working correctly.Do you mean that links to
<front>don't get rewritten back properly, or that links aren't rewriting properly from<front>?Comment #3
sillygwailo"Do you mean that links to don't get rewritten back properly"
That's what I mean.
Assumptions:
<front><front>is not in the list of pages to serve securelyThe URL in the link is written as https://example.com/ All other links get rewritten (say http://example.com/about for example) properly.
Comment #4
neilnz commentedYou're quite right, it seems
<front>isn't translated before being passed to url_alter. I've revised it to make the substitution, but it may have unwanted side effects by altering $path by reference to no longer be<front>(if some other rewrite hook was expecting it to be intact?)Comment #5
neilnz commentedSorry, rerolled the patch without my custom readme.
Comment #6
sillygwailoNow with this patch, links to the
<front>page not rewritten at all. That is, they are insecure if the page you're visiting is insecure, or secure if the page you're visiting is secure. The patch still works correctly for links like 'about', etc.Will the first if statement ever resolve to TRUE? When I look at $path as passed to the hook, it appears to be an empty string when the path in question is
<front>.Comment #7
mstef commentededit
Comment #8
halcyonCorsair commentedRerolled with:
git diff --no-prefix --relative
Comment #9
acbramley commentedAwesome, works well. Fixed a bug we were having with IE not initiating HTTPS as well.
Comment #10
patrickroma commentedIs there a way to force http:// for the frontpage?
Comment #11
patrickroma commentedUpdate
With Boost enabled everything works fine with this patch.
Whenever a webform node is secured via SSL clicking on a normal not secured link it switches back to http://. Only the frontpage is just using the protocol where you came from...
Example:
Clicking from http://mysite.com >> https://mysite.com/webform works. If I know click back to home from https://mysite.com/webform >> https://mysite.com is still get the https on the homepage. This behaviour is only for
<front>- all other urls are switching exactly as supposed to.Is there a way to modify this patch, so that frontpage will load in http://? I am also using secure pages (of course) and is not in the selected list for SSL.
Any help would be really aprecciated - I tried already 3 days to find this trick.
Comment #12
patrickroma commentedStill need help with that... :-(
Comment #13
ArtActivator.com commentedSupport for D7 version?
Comment #14
ArtActivator.com commentedOk I wrote it by myself. The D7 version:
I wrote it because securepages with SWITCH back enabled was incompatible with boost module. Hope that will help someone.
-----------------------
www.ArtActivator.com - Order your success!
Comment #15
gordon commentedCan you please roll this as a patch so it can be tested easier.
Comment #16
rooby commentedHere is the code from #14 in a patch.
I have not tested it or anything, just rolled the patch.
Comment #17
gordon commentedI have done some testing of this, and there was a problem with securepages_can_alter_url() wanting external fields so it was always rejecting, since hook_url_outbound_alter() is passing an internal url (ie. node/1 or user/1)
This should be fine, but if you can check this to make sure it doesn't break anything.
Comment #18
astonvictor commentedI'm closing it because the issue was created a long time ago without any further steps.
if you still need it then raise a new one.
thanks