It would be usefull to also have a checkbox where one could enable http, https or both.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | https_redirection_support-2398503-10.patch | 4.88 KB | jibus |
It would be usefull to also have a checkbox where one could enable http, https or both.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | https_redirection_support-2398503-10.patch | 4.88 KB | jibus |
Comments
Comment #1
jibus commentedRedirect all http trafic to https you mean ?
Comment #2
neograph734Yes, drupal has a check in htaccess to see if the user came from https and then redirects to www. Or non www. with the given protocol. But there is no option to force always https. Or always http.
Having a checkbox that adds https rewrite to the htaccess would be an addition to this module.
Comment #3
jibus commentedSo, a short form with 3 radios :
- Allow trafic from both http and https (default)
- Force all trafic through http protocal only
- Force all trafic trough https protocol only
(label won't be the same, but its just to have an idea)
What can possibility go wrong ? If https is not configured correctly, the all site could crash. We need to detect if https is on.
Anything else ?
Comment #4
neograph734The only extra thing I can think of is to limit the number of redirects to a minimum for speed and SEO reasons.
So it would be wrong to do something like this:
Better would be to do all in one, so you might need to combine this with the part that forces www.
Comment #5
jibus commentedI think we can manage to avoid multiple redirection.
Depending of the choice, we adapt the rewrite rules, imo.
On one of my site , i have this before the drupal redirect rules
I am not an expert in Apache rules, but maybe we can rewrite these parts depending of the option choosen by the user
Comment #6
neograph734That seems quite easy. If https is required an extra 's' could be added in the rewrite rule after the fixed 'http'.
Regular Drupal .htaccess
Lines 59-64
Lines 89-94
Mimicing this will give the desired effect.
Proposion
Add 3 variables for the 3 oprions in #3.
Default
http
RewriteRule ^ - [E=protossl]https
RewriteRule ^ - [E=protossl:s]Both redirects
So the options on the form would control the ouput of the protossl environmental variable. Would something like that work?
Comment #7
jibus commentedIt requires some tests but yes.
I will write a patch based on your contribution.
Comment #8
neograph734Awsome, looking forward to test this :)
Comment #9
neograph734Hi Jibus, do you perhaps have any news about the patch?
Comment #10
jibus commentedWill work on this, this week
Comment #11
jibus commentedSorry for taking so long...
This patch add two options :
- HTTPS_mixed_mode (default) : Enable mixed-mode HTTP/HTTPS (allow trafic from both HTTP and HTTPS. This is the standart drupal behavior
- HTTPS_force_redirect : Enable HTTPS and redirect all HTTP trafic (force all trafic through HTTPS protocol only)
Comment #12
neograph734Thanks for getting back to me :)
I've discovered some issues:
- There is a semilicon in htaccess.admin.inc line 448 (patch line 29) that breaks the htaccess admin ui.
- There appear to be semilocons missing at ends of lines 458, 465 (patch 42 & 52) also breaking the admin ui. (This is actually a new issue as it already was like this on dev). Adding them made the page work again.
- The patch replaces content in htaccess, but since everyting is handled in the www redirect section, this gets never replaced; resulting in an invalid htaccess file. This part can be removed from the patch:
- Following the pattern, it either switches to https if www is to be added or removed. In the case we force users to www, the htaccess files checks if there is www in the url and performs the replacement. This means http://example.com, which is missing www, will be rewritten to https://www.example.com, but http://www.example.com won't.
I solved this in the past by adding the following snippet to the custom settings field, but that does result in a second redirect:
I'll see what happend if we'd add this snippet just above the redirects and replace the last [L] with a chain [C] so the next set of rules will be processed as well. But I am no htaccess expert unfortunately.
Thanks for the patch and I'll let you know what I find!
Comment #13
jibus commentedThanks for your comment. I didn't test enough... I committed the changes and fixed the error you mentionned.
There's the last and important concern about the rewritting of the domain if https redirect is enable. I think in that case, we have to add some custom code :
In htaccess, after the code:
RewriteEngine onadd
shoud do the work
Comment #14
neograph734I've been using the last code block of my last comment to do just this. This is a little more flexible then simply rewriting to domain.com. Today I've been trying to find out what the x-forwarded-proto line was for (I found the snippet some time ago) but I am not sure. I think to remember it was required for some configururations and therefore I left it in.
Comment #15
jibus commentedYour last block has been added when the user select the option : Enable HTTPS and redirect all HTTP trafic (force all trafic through HTTPS protocol only).
Comment #16
neograph734I'll have a look soon. Thanks!
Comment #17
neograph734This seems to be working nicely, will report in any errors occur in the following days.
Comment #18
neograph734I believe this is working nicely. The htaccess file is looking and working as expected. I'd say this is RTBC.
Comment #19
jibus commentedThanks !
Comment #20
neograph734Just a heads up, but you might want to add https support to the module description page. I believe it will convince more people to use the module.
And thank you!
Comment #21
jibus commentedAdded, thanks !