User tests: Successful: Unsuccessful:
Joomla has been improving its SEO performance constantly and one issue which is still open is the behavior of trailing slashes in URLs. Right now, Joomla has largely been following a no-trailing-slashes policy, however we never enforced this. At the same time, some SEO people wanted to have trailing slashes on all URLs. This PR introduces this feature.
This introduces 2 new settings in the SEF system plugin. The first setting lets you decide if you want to have a trailing slash, no trailing slash or no special behavior (which is the b/c setting). Depending on the setting, it either adds or removes all trailing slashes.
The second setting is available when one of the former options is set and redirects a GET request with missing or trailing slash to the "correct" URL with a 301 depending on the other option.
This PR depends on #42692.
I'd like to thank djumla GmbH for sponsoring this feature.
$uri->setPath($uri->getPath() . '/' . $tmp . '/');
Please select:
Documentation link for docs.joomla.org: https://docs.joomla.org/Search_Engine_Friendly_URLs
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
Status | New | ⇒ | Pending |
Category | ⇒ | Administration Language & Strings Front End Plugins |
Labels |
Added:
Language Change
PR-5.1-dev
|
To 1.: it is a difference if we output wrong URLs and then redirect in the htaccess or do it correct right away. Yes, the redirect could be done in the htaccess, but that requires error prone actions from the user, while this here is the simpler solution.
To 2.: no, since these options are not stored in the configuration.php.
To 3.: the PR is not merged yet, is it. ? Documentation is on its way and will be combined with the other 2 router related PRs.
I have tested this item ? unsuccessfully on 131eafe
Tested with both of the following
In both cases with the sample joomla data I observed no trailing slash in the url
no I didnt see that
I have not tested this item.
I have tested this item ✅ successfully on d49ccdf
Work as described!
I have tested this item ✅ successfully on d49ccdf
Status | Pending | ⇒ | Ready to Commit |
Setting RTC as it has 2 good tests, but setting also the RMDG (release manager decision queue) label because this PR is subject of discussion among maintainers.
Labels |
Added:
RTC
RMDQ
|
In the CMS Maintainer meeting we talked about this PR and decided to join the two options into one. So if you decide for one behavior, it automatically also means when the URL is not as expected, it does a redirect to the right one. I made the necessary changes. @SniperSister and @viocassel would you be able to test this again?
Status | Ready to Commit | ⇒ | Pending |
Back to pending
I have tested this item ✅ successfully on baac8cd
I have tested this item ✅ successfully on baac8cd
Status | Pending | ⇒ | Ready to Commit |
RTC
Labels |
Removed:
RMDQ
|
Status | Ready to Commit | ⇒ | Pending |
Back to pending as the PR has received a change. @SniperSister @viocassel Could you test again? Thanks in advance.
I have tested this item ✅ successfully on a9f1b3c
Works as expected and fixes the issue caught by Martina
I have tested this item ✅ successfully on a9f1b3c
?
Status | Pending | ⇒ | Ready to Commit |
RTC
This should be retested as there has been a change
After some discussions, we decided to switch this to use 301 redirects instead of 303s.
Status | Ready to Commit | ⇒ | Pending |
Back to pending as there have been made changes.
@SniperSister @viocassel Could you test again? Thanks in advance.
I have tested this item ✅ successfully on 74383a3
I have tested this item ✅ successfully on 74383a3
Status | Pending | ⇒ | Ready to Commit |
RTC
Link to documentation has been added.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-02-28 17:39:57 |
Closed_By | ⇒ | LadySolveig |
Thank you @Hackwar and for testing and support @SniperSister @viocassel @richard67
Thank you!
Thank you very much for this @Hackwar ! I'm glad it didn't get dismissed.
my 2c on the importance:
according to Google's Martin Splitt, who I had a conversation with on this topic late last year, this still counts: https://developers.google.com/search/blog/2010/04/to-slash-or-not-to-slash?hl=en
tl;dr:
Trailing slashes do matter to Google. Traditionally that comes from url w/ trailing slash being seen as directory and url w/o trailing slash as file. Google respects same urls with and without trailing slashes to have different content, even.
On the other hand, if e.g. https://mysite.com/blog and https://mysite.com/blog/ show the same content, Google may punish you for duplicate content and even if that's not the case, your "Link Juice" will be split 50/50, so instead of getting one better ranked entry in the SERPs, you get 2 worse.
So even if a large % of users will not actively use it, if there is a default behaviour for either with or without trailing slash, still all users will profit from the SEO impact.
You're welcome. ;-)
Thank you Hackwar for bringing this finally into the joomla core! :-)
Are you sure the slashes are working in the attachBuildRule part? Appears to be a bit of number bonanza on the trailingslash param: 1 and 2 in onAfterInitialise 0 and 1 in enforceTrailingSlash
2. the description is confusing "Remove unneeded index.php from URLs" because it sounds the same as the existing option which removes index.php