10

I'm using MODX Revolution 2.2.4-pl. I'm using the supplied .htaccess file and have friendly URLs turned on. These are my rewrite rules.

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

What do they need to look like to have it remove the .HTML from the URL?

I've been googling this for the past twenty minutes and my solutions have not worked. Thanks

OptimusCrime
  • 14,662
  • 13
  • 58
  • 96
Brant
  • 1,764
  • 11
  • 18

3 Answers3

31

There is a much easier built in 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 you have erased the content, clear cache.

MODX Evolution

Go to Tools -> Configuration -> Friendly URLs.

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

OptimusCrime
  • 14,662
  • 13
  • 58
  • 96
  • 3
    +1 This is the 'MODX way': more efficient than the .htaccess solution, allowing 'direct' access to the resource rather than going through a rewrite on every request. If there are existing external links pointing to the pages ending in .html it would be a good idea to use the RewriteRule as well. – okyanet Sep 05 '12 at 02:52
  • I would concur. This is a straightforward way to do this, without complicated .htaccess rules. – Xofo Jan 01 '20 at 06:09
3

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]
Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
1

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

It is trying to redirect all requests that come into the site that are not for an actual file or directory (i.e. images, css, or other scripts that might not be a part of the "main" website) to a 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 a front controller), but have them use clean URL's then you will need to use a different sort of rewrite. Probably something more like

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

This rule would take a request in the form of http://domain.com/somepage and have it silently point to http://domain.com/somepage.html to serve the request.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103