-4

I'm trying to use the User-Friendly-URL feature of MODX Revolution v2.2.14-pl (sdk) to eliminate the .html extension from the URL. An already clean URL redirects to the home page rather than showing the correct page. Why does the first URL redirect to the home page?

  1. /modx_revolution/zwei/ shows 'Home' page
  2. /modx_revolution/zwei.html shows correct page

I've read that until the MODX and Browser caches are emptied the changed pages can only be viewed with the Preview function, which gives the URL from Example 2. Even after cleaning both caches the first url does not work. I think that the URL-settings or htaccess are wrong somehow.

MODX Friendly URL settings:

friendly_urls: true
friendly_urls_strict: true
use_alias_path: true

.htaccess:

RewriteEngine On
RewriteBase /modx_revolution/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
davidism
  • 121,510
  • 29
  • 395
  • 339
toesslab
  • 5,092
  • 8
  • 43
  • 62
  • This catches a lot of people out: by default, the `error_page` setting (for returning 404s) is set to the home page. So your first url might be returning a 404 not found error code, but displaying the home page. Try changing the `error_page` setting to a different page and see if the first url sends you there instead? – okyanet Apr 27 '14 at 13:17
  • To remove the `.html` extension, go to *System > Content Types* and clear out the File Extension column for the HTML content type. – okyanet Apr 27 '14 at 13:19
  • @okaynet Are you sure thats a good idea? – toesslab Apr 27 '14 at 13:34
  • @okaynet Could you pls see my edited question? Hope you can help, cause the ressource does exist – toesslab Apr 27 '14 at 14:53
  • Yes I'm sure. See http://forums.modx.com/thread/30437/avoiding-using-html-extension, 'opengeek' is the lead dev. – okyanet Apr 28 '14 at 03:05
  • Re: edited question - It's not really clear what you're after. Is `/zwei` loading the page correctly, but `/zwei/` is not? If this is the case, change the resource to a container and that should work. – okyanet Apr 28 '14 at 03:10
  • zwei.html is loading and zwei or zwei/ not – toesslab Apr 28 '14 at 04:11
  • @okaynet If u'd put your advice in an answer, I'll vote it... Or should i rather delete question for being too specific? – toesslab Apr 28 '14 at 04:48

1 Answers1

2

This catches a lot of people out: by default, the error_page setting (for returning 404s) is set to the home page. So your first url might be returning a 404 not found error code, but displaying the home page.

Try changing the error_page setting to a different page and see if the first url sends you there instead?

To remove the .html extension, go to System > Content Types and clear out the File Extension column for the HTML content type. You may need to clear your Site Cache after doing this for the changes to take effect.

okyanet
  • 3,106
  • 1
  • 22
  • 16
  • The slash in the end indicates that the URL is a container. If you don't want the .html you could go to the resource and check "Container" under settings. – Kristian Sandström Apr 28 '14 at 11:14