Friendly Urls

friendly urls Internal SEO optimization

Setting up the CNC in MODX consists of several steps.

Renaming the ht.access

The ht.access file is in the root folder of the site, rename it to .htaccess. This can be done via FTP / SFTP or through the hosting file manager. By default, you will not be able to rename it from the admin panel without making the setting in upload_files.

Installing the transliteration package

Install the transliteration add-on from the main repository: translit. How to install packages, see the lesson: Installing the necessary add-ons (packages).

MODX System Settings — Friendly URLs

Go to «System Settings», on the page that opens, in the filter, select «Friendly URL». Next, find the following items and set the corresponding values:

  • FURL Alias Maximum Length – friendly_alias_max_length – 70 (more than 70 characters results in a too long page address).
  • FURL Alias Real-Time – friendly_alias_realtime – Yes (generates an alias in real time).
  • FURL Alias Character Restriction Method – friendly_alias_restrict_chars – alphanumeric (so that everything except letters and numbers are cut out from the alias).
  • FURL Alias Character Restriction Pattern – friendly_alias_restrict_chars_pattern – /[\0\x0B\t\n\r\f\a&=+%#<>”~:`@\?\[\]\{\}\(\)\,\|\^’\\]/
  • Use friendly URLs – friendly_urls – Yes (include URLs like /o-nas.html or /about-us.html (transliteration of aliases), not parametric ones like /index.php?p=3 (to support this option on some hostings, you need the appropriate Apache web server settings in the .htaccess file or in the Nginx config file).
  • Use Strict Friendly URLs – friendly_urls_strict – Yes.
  • Check for Duplicate URIs Across All Contexts – global_duplicate_uri_check – Yes (for multilingual sites No).
  • Use Friendly Alias Path – use_alias_path – Yes (this is for a nested structure, example: modx3.com/blog/name-statya, if you set No, it will simply be modx3.com/name-statya).
  • Use Frozen Parent URIs – use_frozen_parent_uris – any (optional).

Here is an example of all settings with a nested structure):

Configured SPC in MODX 3

If you haven’t done the basic settings, I recommend changing the setting in the Gateway category: Strict request method — request_method_strict — Yes

So that links work only in the CHPU-form via redirect and do not open via links like https://site.ru/index.php?id=7

That’s it! We now have CHPU like /about.html.

Friendly URLs not working? Don’t forget about server requirements:
The server (Apache) must have Mod_Rewrite enabled.

Additionally: setting up a base URL

If you are following the lessons in the documentation consistently, you don’t need to do this step yet – we’ll do it when you stretch the template.

Check if you have the <base href=""> parameter in your templates (or chunk) in the head section:

<head>
<base href="[[!++site_url]]">
...
</head>

If it is not there, write it — without it there will be problems with duplicating the URL relative to the current page and when switching to another page.

In order to remove .html from the URL, you need to go to the main menu in “Content” – “Content types” and remove the .html extension.

Remove the html extension

Then if the site is operational (with pages), update the site cache and update the link URL (management – clear cache).

Rate article
MODX 3
Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.