How to remove .html from Friendly URL - Modx?

I am using MODX Revolution 2.2.4-pl. I use the provided .htaccess file and include friendly URLs. These are my rewriting rules.

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 

Why does it need to remove .HTML from a URL?

I tried this in the last twenty minutes and my solutions did not work. Thanks

+8
html .htaccess modx modx-revolution
source share
3 answers

There is a much simpler way. Log in to the Manager.

MODX Revolution

2.2.x and earlier: go to System -> Content Types .

2.3.x and later: go to Content -> Content Types .

Find HTML and erase what is written in "File Extension". You do this by double-clicking .html in the table to activate the editable field. After deleting the contents, clear the cache.

MODX Evolution

Go to Tools -> Configuration -> Friendly URLs .

Delete content in the "Friendly Suffix URL". Save and clear the cache.

+23
source share

This works for me:

 # The Friendly URLs part #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] RewriteCond %{REQUEST_URI} \.html$ RewriteRule ^(.*)\.html$ $1 [R=301,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] #RewriteRule . /index.php [L] 
+3
source share

First, I think you need to understand what this .htaccess is trying to do.

It tries to redirect all requests that come to the site that are not the actual file or directory (for example, images, css or other scripts that cannot be part of the "main" website) to the front controller located at index.php.

If what you are trying to do is use a bunch of * .html files on your site (and not the front controller), but use them in a clean URL, then you will need to use a different type of rewrite. Probably something more like

 RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.*)$ $1.html [L,QSA] 

This rule will accept the request as http://domain.com/somepage and quietly point to http://domain.com/somepage.html to serve the request.

+1
source share

All Articles