On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hello,

    I'm wondering if anybody would be able to help with 2 issues I'm having which relate to the rules I want to add to the .htaccess file to do with URLs yet I believe these aren't working due to system settings within Modx overriding what I'm trying to do (I admit I could be wrong with this).

    The first problem I've had is that I've been asked to ensure that all URL's don't contain a trailing slash at the end. Now I know that by removing / from container_suffix in the system settings this ensures the any item used as a container will not finish with /. The problem I have is that I've tried to write an additional rule to the .htaccess that should someone type the URL and add a trailing slash it would resolve to without rather than going to a 404 error page. I've tried to use something like:-

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} (.*)$
    RewriteRule ^(.+)/$ http://www.%{HTTP_HOST}/$1 [R=301,L]


    The second issue is that I've been asked to have something written in the .htaccess file which creates a 301 redirect for URL's with https to http whereby I've used the following:-

    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


    I admit that my knowledge on regex expressions isn't great and that could be where I'm going wrong yet I wondered if anyone could help as to where I'm going wrong.

    Kind Regards

    Graham
    • I have made progress with the second issue whereby having:-

      RewriteCond %{HTTPS} on
      RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L]


      This will redirect users to HTTP yet then displays the URL as /index.php?q=pagename.