Problem/Motivation
The configuration page, under "URL prefix redirect", offers a toggle between two options:
- Without WWW prefix
- With WWW prefix
With the additional help text:
Users will be redirected corresponding to the selected option.
Make sure your site is accessible for the option selected.
Some potential new users of the module (as me today) may have problems understanding what those two options do, and which one to choose.
For example does "Without WWW prefix" mean that the redirect
Proposed resolution
If you can clarify, I am happy to suggest adjusted wording, and to also translate the configuration form into French.
Comments
Comment #2
enzipher commentedHey, and thanks for the report.
The options you see on the admin settings page is how you want your domain to appear to the end user, so it would be the second option you presented. I.e. if you select "Without WWW prefix" the user will be redirected to a URL without WWW.
I can understand the confusion though, and if you have any better wording I will take that into consideration.
That said, the overall naming here should probably be updated as it's not really correct to start with. The "www" part is a subdomain, and if it's a prefix to anything it's to the "root domain". In any case, the intent is that the wording should be easy to understand by any non-technical person.
Thanks,
Comment #3
agaq commentedHi there,
Thanks for the prompt response.
Suggestion
So, could it be something like:
URL prefix redirect
(examples below are for a site that can be accessed using EITHER http(s)://mydomain.com OR http(s)://www.mydomain.com)
(_) Remove WWW prefix (redirect www.mydomain.com to mydomain.com)
(_) Add WWW prefix (redirect mydomain.com to www.mydomain.com)
Users will be redirected corresponding to the selected option.
ATTENTION: Make sure your site is accessible both with and without the WWW prefix.
HTTP Secure (HTTPS) redirect
(_) No redirect (The site remains accessible via http, as well as (if enabled) via https)
(_) Redirect to HTTPS (The site becomes accessible only via https: all http requests are redirected to https)
ATTENTION: if you choose to redirect to HTTPS, make sure your site is accessible by HTTPS, and that your SSL certificate is valid.
For more information, see https://www.drupal.org/https-information.
Assumptions made
The wording suggested above is making the following assumptions, which may or may not be correct:
(1) the prefix redirect works only for the WWW prefix, not any other prefix.
If for example the site was accessible using either http(s)://mydomain.com or http(s)://forum.mydomain.com, then:
- "Remove WWW prefix" would not remove "forum" and not redirect forum.mydomain.com to mydomain.com (ie the search is done on "www." not on any alphanumeric prefix value.)
- "Add WWW prefix" would add the prefix and redirect mydomaine.com to www.mydomain.com, which would not be a valid URL for the site.
That is consistent with the normal practice to have a domain's primary site to be accessed by or advertised as either "mydomain.com" or "www.mydomain.com", with other prefixes being used for "additional" sites or services, eg cloud.mydomain.com, jitsi.mydomain.com, help.mydomain.com, etc. You would not normally want mydomain.com redirect to help.mydomain.com or vice-versa.
(2) "No redirect (to HTTPS)" does not require the site to have HTTPS enabled.
Question
Is there any particular reason why you cannot enable "Redirect to HTTPS" without also enabling URL prefix redirect?
Would that be possible and more flexible to have something like the following?
[yes/no] Enable URL prefix redirect
(_) Remove WWW prefix
(_) Add WWW prefix
[yes/no] Enable Redirect to HTTPS
Comment #4
agaq commentedHello
I had a quick look around inside the module and found that code:
The check is done, using a case sensitive comparison, on the first 4 characters of the URL being "WWW." (with W upper case).
So, unless $host has been transformed to upper case earlier on, the behaviour as I understand it is:
1) If we choose to Add WWW prefix ($use_prefix is true), the redirection is activated whenever the URL does NOT start with "WWW." (upper case Ws), so:
mydomain.com will redirect to WWW.mydomain.com
BUT
www.mydomain.com will be redirected to WWW.www.mydomain.com
drupal.mydomain.com will be redirected to WWW.drupal.mydomain.com
2) If we choose to Remove WWW prefix ($use_prefix is false), the redirection is activated whenever the URL DOES start with "WWW." (upper case Ws), so
WWW.mydomain.com will be redirected to mydomain.com
BUT
www.mydomain.com will not be redirected
drupal.mydomain.com will not be redirected
-
Is that correct?
Comment #5
enzipher commentedHey, thanks for the write-up!
At a quick glance that looks pretty good.
I'd need some time to review it in more detail though.
Thanks,
Comment #6
agaq commentedLet me know when you have adjusted the wording, and if you want me to provide a French translation for it. Cheers.
Comment #7
enzipher commentedI needed to fix #3330069: Drupal Coding Standards Issues | phpcs before getting to this, but I'm on it and will provide an update as soon as I can.
I actually overlooked your other comment on the potential case issue. I haven't reviewed that one yet, but it should preferably have its own Issue as this one covers the clarification only. One problem per Issue is the general rule, but thanks for bringing it up.
French translation would certainly be welcome once the text has been updated.
Comment #8
enzipher commentedI had a quick look at the case issue, and the getHost() method is always returning a lowercase string (as per RFC 952/2181), so there will never be a case comparison issue.
My initial thought was that you simple shouldn't use both, but I do agree that it should be up to the user to make that decision as there might be edge cases where it's needed.
Apart from the text changes there are some changes to logic as well, which needs to be done with care to ensure backwards compatibility.
Otherwise your assumptions are correct regarding redirects. With the addition that
forum.mydomain.comwould actually get the www prefix if enabled. I've added a separate issue for that bug (#3335425: The www prefix is added to sub-domains).Thanks,
Comment #9
enzipher commentedI did some updates on my local. Feel free to review the attached image and let me know if it makes sense to you.
Comment #10
agaq commentedYes, it does make sense to me.
Just a typo in the comment for the Domain prefix / No redirect option: it should be "are accessible" instead of "is accessible"
My suggestion for translation in French below, under the English.
===
Text in English:
Domain prefix
(_) No redirect
Both mydomain.com and www.mydomain.com are accessible. Only use this option if you are certain it is needed.
(_) Remove WWW prefix
Redirect www.mydomain.com to mydomain.com.
(_) Add WWW prefix
Redirect mydomain.com to www.mydomain.com.
HTTP Secure (HTTPS) redirect
(_) No redirect
The site remains accessible via HTTP, as well as via HTTPS (if enabled).
(_) Redirect to HTTPS
The site becomes accessible only via HTTPS. All HTTP requests are redirected to HTTPS.
ATTENTION: if you choose this option, make sure your site is accessible by HTTPS, and that your SSL certificate is valid.
For more information, see https://www.drupal.org/https-information.
Text in French:
Préfixe du domaine
(_) Pas de redirection
mydomain.com et www.mydomain.com sont tous deux accessibles. N'utilisez cette option que si vous êtes certain qu'elle est nécessaire.
(_) Supprimer le préfixe WWW
Rediriger www.mydomain.com vers mydomain.com.
(_) Ajouter le préfixe WWW
Rediriger mydomain.com vers www.mydomain.com.
Redirection HTTP Secure (HTTPS)
(_) Pas de redirection
Le site reste accessible via HTTP, ainsi que via HTTPS (si activé).
(_) Redirection vers HTTPS
Le site devient accessible uniquement via HTTPS. Toutes les requêtes HTTP sont redirigées vers HTTPS.
ATTENTION : si vous choisissez cette option, assurez-vous que votre site est accessible par HTTPS, et que votre certificat SSL est valide.
Pour plus d'informations, voir https://www.drupal.org/https-information.
Comment #11
enzipher commentedGreat, thanks!
I'll implement this along with the French translation. Also thanks for catching the typo.
Comment #14
enzipher commentedHey. So I've been doing a bit of maintenance and incorporated the updated texts. It's all available in the 2.1.0 release.
Now for translations, the correct way of doing it is to go through https://localize.drupal.org. I have not done this myself, so I'm not exactly sure what the exact procedure is, but I would suggest going to that site and read up on the docs. I know it involves signing up for the language specific translation team though, in your case that would be https://localize.drupal.org/translate/languages/fr.
The release to translate strings for would be version 2.1.0.
https://localize.drupal.org/translate/languages/fr/translate?project=htt...
I will mark this ticket as fixed as there's nothing more to do here. I'm not sure if I can be of any more help for the translations, but feel free to contact me if there's anything you believe I can assist with, or if appropriate, open a new ticket.
Thanks for your help!