Home page » Blog » SEO-friendly URLs for the Legal Tools module

SEO-friendly URLs for the Legal Tools module

The Legal Tools module is a must-have for every public HumHub network to add imprint, terms of use, privacy policy and cookie notice.

Would you like to see these pages with the new SEO module for search engines, this is not possible directly. Because the URLs of the pages are something like this yourdomain.com/legal/page/view?pageKey=terms This is not particularly SEO friendly and is not supported by the SEO module.

However, it can easily be adjusted in your file configuration so that the URL is yourdomain.com/terms .

Attention: Before you make any changes to your configuration file, copy the file so you can restore it in case of a mistake. Even a small typo can make your network unreachable.

The configuration file can be found at protected/config/common.php There should already be showScriptName on false and enablePrettyUrl on true Because without PrettyURLs the SEO module does not work.

Now add rules to the file as follows:

<?php
return [
    'components' => [
        'urlManager' => [
            'showScriptName' => false,
            'enablePrettyUrl' => true,
            'rules' => [
                [
                    'pattern' => 'terms',
                    'route' => 'legal/page/view',
                    'defaults' => ['pageKey' => 'terms']
                ],
                [
                    'pattern' => 'imprint',
                    'route' => 'legal/page/view',
                    'defaults' => ['pageKey' => 'imprint']
                ],
                [
                    'pattern' => 'privacy',
                    'route' => 'legal/page/view',
                    'defaults' => ['pageKey' => 'privacy']
                ]
            ],
        ],
    ]
];

And that's it. Now you can, for example, find your Terms at yourdomain.com/terms and use the SEO mode to edit your SEO settings.

This guide has been tested with the following versions:

  • HumHub: 1.15
  • Legal Tools module: 1.4.1
  • SEO module: 1.0.0-beta.1
  • PHP: 8.2

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Basket
Scroll to Top