lcp

How to Enable Friendly URLs in MODx?

By default the MODx installation archive comes with a ht.access file that contains the rewrite rules for your website. That file’s rules will not become active until it is renamed to:

.htaccess

Once done with editing it, open the file with a text editor like notepad and edit the following lines:

RewriteEngine On

RewriteBase /

# Rewrite www.domain.com -> domain.com — used with SEO Strict URLs plugin

#RewriteCond %{HTTP_HOST} .

#RewriteCond %{HTTP_HOST} !^example-domain-please-change.com [NC]

#RewriteRule (.*) https://example-domain-please-change.com/$1 [R=301,L]

And edit them to:

RewriteEngine On

RewriteBase /

# Rewrite www.domain.com -> domain.com — used with SEO Strict URLs plugin

RewriteCond %{HTTP_HOST} .

RewriteCond %{HTTP_HOST} !^example-domain-please-change.com [NC]

RewriteRule (.*) https://example-domain-please-change.com/$1 [R=301,L]

In the above example, make sure to edit example-domain-please-change.com to your own domain. For example, if your domain is: yourdomain.com , the lines should look like:

RewriteEngine On

RewriteBase /

# Rewrite www.domain.com -> domain.com — used with SEO Strict URLs plugin

RewriteCond %{HTTP_HOST} .

RewriteCond %{HTTP_HOST} !^yourdomain.com [NC]

RewriteRule (.*) https://yourdomain.com/$1 [R=301,L]

Note: if your MODx is installed in a subfolder of your /public_html/ directory, for example if your script is located in /public_html/modx/ the first rule should look like:

RewriteBase /modxThe next thing you will need to do is edit your template. You will have to make sure your template has the following line:

<base href=”[[!++site_url]]” />

Now clear your MODx cache and you are done.

For reference: https://rtfm.modx.com/revolution/2.x/administering-your-site/using-friendly-urls