We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10152
    • 156 Posts
    Hello,

    these .htaccess rules allow clean urls for custom $_GET values inside a folder, it may help someone.

    In my case i want to change :
    http://mysite.com/mydirectory/?size=big

    into ->
    http://mysite.com/mydirectory/big/


    So after hours of struggle, and facing several problems with stylesheets and the manager :
    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Add these 2 lines here
    RewriteRule ^mydirectory/([0-9A-Za-z]+)/$ mydirectory/?param=$1 [L,QSA]         
    RewriteRule ^(manager|assets|core|connectors) - [L]  # <-- if not present, stylesheets and manager won't load                                                     
    
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    

    Don’t change the order of the rules. Works fine on localhost.
      • 22303 MODX Staff
      • 10,725 Posts
      It’s much better IMO to use $modx->sendForward in a plugin on the event OnPageNotFound to do this rather than add additional burdens and potential problems by adding new mod_rewrite rules. Or at least I feel like I have more control over what is happening this way in any case. Also, using extra rewrite_rules for this makes your site less portable.

      See this post for an example.