No Code Attached Yet
avatar ptest8794
ptest8794
23 Sep 2022

to add trailing slashes in the URL you need to edit the file

public_html/libraries/src/Router/SiteRouter.php

public function buildRewrite(&$router, &$uri)
{
// Get the path data
$route = $uri->getPath();

    // Transform the route
    if ($route === 'index.php') {
        $route = '';
    } else {
        $route = str_replace('index.php/', '', $route);
    }

    $uri->setPath($route);
}

add the string. '/' in the following line of code

$uri->setPath($route . '/');

I was wondering if it is possible to add as a new feature to be activated from the admin area

avatar ptest8794 ptest8794 - open - 23 Sep 2022
avatar ptest8794 ptest8794 - change - 23 Sep 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 23 Sep 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 23 Sep 2022
avatar ptest8794 ptest8794 - change - 23 Sep 2022
The description was changed
avatar ptest8794 ptest8794 - edited - 23 Sep 2022
avatar brianteeman
brianteeman - comment - 24 Sep 2022

Why would you want to do this?

avatar ptest8794
ptest8794 - comment - 24 Sep 2022

To add trailing slash without any plugin or htaccess code.
Do you think is possible add this new feature?

avatar richard67
richard67 - comment - 5 Oct 2022

Trailing slashes should - if ever - not be added to ANY URL but only to those of directory stile, e.g. "www.some-domain.com/en/" or "www.some-domain.com/de/", but not "www.some-domain.com/index.php/" or "www.some-domain.com/somecategory/somealias.html/". As it is possible to switch on suffix (e.g. ".html") in the configron, your proposed solution is simply wrong and would break such URLs. Your solution may for you in your particular use case but not for everybody.

avatar ptest8794
ptest8794 - comment - 5 Oct 2022

In Fact I mean this solution for cases like www.domain.com/en/category/ or www.domain.com/en/category/article/

I was wondering if it is possbile add this feature with a switch in the web admin area and if the suffix was enabled the trailing slashes button has to set to no add or disabled.

avatar richard67
richard67 - comment - 5 Oct 2022

Well the trailing slashes are a relict from old times. Meanwhile Google doesn't recommend or require them anymore. They do not do any harm, but they also serve no benefit.

avatar joomdonation
joomdonation - comment - 14 Nov 2022

Guess this issue could be closed. @richard67 Could you please make final decision here?

avatar richard67
richard67 - comment - 14 Nov 2022

@joomdonation I don’t like to make decisions. Maybe move it to discussions?

avatar joomdonation
joomdonation - comment - 14 Nov 2022

OK. Thanks. I'm moving this to discussions so that it could be discussed further if needed.

avatar joomdonation joomdonation - change - 14 Nov 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-11-14 07:37:11
Closed_By joomdonation
avatar joomdonation joomdonation - close - 14 Nov 2022

Add a Comment

Login with GitHub to post a comment