J3 Issue ?
avatar NickSdot
NickSdot
29 Sep 2017

This is my first created issue here and I hope I did it as informative as possible and correct.
If some information is missing please let me know.

Because of Issue #17996 I had a deeper look into the behavior of the redirect component/plugin.

I think I found a serious issue what affects every Joomla! website which was running on "http" before it was switched to "https".

Steps to reproduce the issue

For this test scenario I cleared the whole redirect table.
So there are no duplicate redirects in the table itself

Test 1
If I add the relative URL "/en/my-old-url.html" as "old_url" the redirecting behavior is as follows:

Case 1.1

  1. access URL http://www.domain.com/en/my-old-url.html (no SSL)
  2. 301 redirect to httpS://www.domain.com/en/my-old-url.html (with SSL) what is a 404 itself
  3. 301 redirect to httpS://www.domain.com/en/my-NEW-url.html

Note: Case 1.1 has a double redirect what is not needed and probably bad for the SEO (crawl budget) of Joomla websites.

Case 1.2

  1. access URL httpS://www.domain.com/en/my-old-url.html (with SSL)
  2. 301 redirect to https://www.domain.com/en/my-NEW-url.html

Note: Case 1.2 works as expected with one single redirect.

Test 2
If I add the absolute URL "http://www.domain.com/en/my-old-url.html" as "old_url" the redirecting behavior is as follows:

Case 2.1

  1. access URL http://www.domain.com/en/my-old-url.html (no SSL)
  2. 301 redirect to httpS://www.domain.com/en/my-NEW-url.html

Note: Case 2.1 works as expected with one single redirect.

Case 2.2

  1. access URL httpS://www.domain.com/en/my-old-url.html (with SSL)
  2. 404 page not found; no redirect

Note: Case 2.2 can not be redirected because there is not redirect rule for the old SSL-url

Test 3
If I add the absolute URL "httpS://www.domain.com/en/my-old-url.html" as "old_url" the redirecting behavior is as follows:

Case 3.1

  1. access URL http://www.domain.com/en/my-old-url.html (no SSL)
  2. 301 redirect to http://www.domain.com/en/my-old-url.html what is a 404 itself
  3. 301 redirect to httpS://www.domain.com/en/my-NEW-url.html

Note: Case 3.1 has a double redirect what is not needed and probably bad for the SEO (crawl budget) of Joomla websites.

Case 3.2

  1. access URL httpS://www.domain.com/en/my-old-url.html (with SSL)
  2. 301 redirect to httpS://www.domain.com/en/my-NEW-url.html

Note: Case 3.2 works as expected.

Expected result

Urls should be redirected no matter if it is an "https" or "http url" to prevent redirects to 404 pages or double redirects.

Actual result

In my opinion the current behavior makes it very complicated to maintain the redirects of a Joomla website. Also there are redirects to 404 pages because of missing matchings.

To make really sure that each case is handled well and without:
• double redirects
• redirects to 404 pages

we have to add at least 2 "old_url" for every url we want to redirect:
http://www.domain.com/en/my-old-url.html
httpS://www.domain.com/en/my-old-url.html

but actually we have to add the relative url
• /en/my-old-url.html

as well to make really sure we´ve catched all possible cases.

System information (as much as possible)

Joomla version:
3.8.0

PHP version:
7.0.13

Force SSL:
Status "2" (force all)

Additional comments

Because I am not quite sure as well about what is the best solution for this I wanted to start this topic.

In my opinion it would make sense to always handling the scheme and host of both, old_url and new_url (if internal url), dynamically.

So let´s say we have this two cases:

a) "force_ssl" is NOT activated in global config
In this case "a" the current behavior should be well, tho?
I don´t see a reason to change the resulting behavior.

b) "force_ssl" is activated in global config
In this case "b" my ideas to change the behavior are...

Handling of "old_url"

Option 1

It doesn´t matter what url of these is used in "old_url"

http://www.domain.com/en/my-old-url.html
httpS://www.domain.com/en/my-old-url.html
• /en/my-old-url.html

it always matches for "https" AND "http" IF "force_ssl" is enabled.

Option 2

Only if "old_url" is relative

• /en/my-old-url.html

it always matches for "https" AND "http" IF "force_ssl" is enabled.

Handling of "new_url"

The uri scheme in the field "new_url" will always be replaced with "https" on redirect IF "force_ssl" is activated and the url is an internal target.
This also avoid a double redirect as well.

avatar NickSdot NickSdot - open - 29 Sep 2017
avatar joomla-cms-bot joomla-cms-bot - change - 29 Sep 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 29 Sep 2017
avatar brianteeman
brianteeman - comment - 29 Sep 2017

Personally it is much better when switching from http to https to use an .htaccess rule to redirect the urls. Using the redirect component just to switch between http and https is very inefficient and resource intensive

avatar NickSdot
NickSdot - comment - 29 Sep 2017

@brianteeman
I agree. But this isn´t really the case or the reason for my topic here.

Maybe I add this additional info...

Years ago the URL was:
http://www.domain.com/en/my-old-url.html

Then the website was switched to SSL:
https://www.domain.com/en/my-old-url.html
(without .htaccess rule because Joomla itself did it perfect by use force_ssl)

After that the URL changed to:
https://www.domain.com/en/my-new-url.html

As you can see this is a mix out of http/https switch (a while ago) and a redirect to "real" new urls (later).

So, even if there would be a 301 .htaccess rule it would be two redirects.

  1. by htaccess
  2. by com_redirect

This is why I think that (at least) a relative URL should redirect both – http and https.

Got me?

avatar brianteeman
brianteeman - comment - 29 Sep 2017

The problem is that technically http and https are two different domains. It is perfectly allowed and possible to have http://www.example.com/page1 and https://www.example.com/page2 as completely different content

avatar NickSdot
NickSdot - comment - 29 Sep 2017

@brianteeman
I see what you mean. Absolutely correct.

But if "force_ssl" is enabled for the whole website (status 2) this is not the case as well, tho?
Because Joomla! itself will redirect all urls to "https" in any way when it is enabled.

Now the redirect plugin always use the current scheme for the relative "old_url".
So all "old" redirects will stop working because the used scheme/host depends on which scheme/host the website will be accessed.

What I thought about was something like this...

if($app->get('force_ssl', 0) === 2):
// handle scheme depending on "force_ssl"; use http AND https as scheme for the redirect source
else:
// handle scheme like now; use current scheme
endif;

This should work for both "old_url" and "new_url" without any backward compatibility problems.

avatar franz-wohlkoenig franz-wohlkoenig - change - 29 Sep 2017
Category com_redirect
avatar franz-wohlkoenig franz-wohlkoenig - change - 29 Sep 2017
Status New Discussion
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 29 Sep 2017

@NickSdot thanks for your first Issue and your clear Comments.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18161.

avatar mbabker
mbabker - comment - 29 Sep 2017

The force SSL option enforces the current URL being HTTPS before we try to route the current request. So the request isn't running far enough to know that the current URI will result in a 404. The same issue will happen if you force HTTPS with a webserver directive (i.e. changes in .htaccess) but don't use the webserver to handle redirecting old URLs as well. So the redirect plugin being unaware of scheme is OK because it won't actually run on a forced HTTPS site (either by Joomla or webserver config) until after a HTTP link has been redirected.

The only possible way to avoid the double redirect coming from Joomla code is to delay the redirect to a point after routing has been completed, but that seems like an inefficient use of server resources to me (a redirect like that should be performed as early as possible in the request, which is why the webserver handling it is the best option).

avatar NickSdot
NickSdot - comment - 29 Sep 2017

@mbabker
Not sure if I get you right.
If I understand you correctly then what I described in "Case 2.1" should not work at all – because the redirect to "https" should happen far way before.

If I add the absolute URL "http://www.domain.com/en/my-old-url.html" as "old_url" the redirecting behavior is as follows:

Case 2.1

  1. access URL http://www.domain.com/en/my-old-url.html (no SSL)
  2. 301 redirect to httpS://www.domain.com/en/my-NEW-url.html

But it is working. Isn´t it?

Can you please point me in the right direction if I get something wrong?
Thanks!

avatar mbabker
mbabker - comment - 29 Sep 2017

I don't know the internals of how the plugin is determining a redirect, but if you're using an absolute URL then it would make sense that http and https schemed URLs are checked separately as explained by Brian. My main point though is the force SSL check/redirect are happening before we try to parse the URI and route to a component, so when you hit the redirect plugin you are already past that point.

avatar brianteeman brianteeman - change - 25 Mar 2018
Labels Added: J3 Issue
avatar brianteeman brianteeman - labeled - 25 Mar 2018
avatar jwaisner jwaisner - change - 11 Mar 2020
Status Discussion Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2020-03-11 20:17:51
Closed_By jwaisner
avatar joomla-cms-bot joomla-cms-bot - change - 11 Mar 2020
Status Expected Behaviour Closed
Closed_By jwaisner joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 11 Mar 2020
avatar joomla-cms-bot
joomla-cms-bot - comment - 11 Mar 2020

Set to "closed" on behalf of @jwaisner by The JTracker Application at issues.joomla.org/joomla-cms/18161

avatar jwaisner
jwaisner - comment - 11 Mar 2020

Closing as this as it could not be confirmed as a bug.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18161.

Add a Comment

Login with GitHub to post a comment