We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14258
    • 10 Posts
    Converted my site to Revolution & love it. 1 problem left to solve.

    www.example.com/learn.html is not the same as www.example.com/LEARN.com

    The url has to be an exact match (its case sensitive). In my .htaccess I have the following:

    # Friendly URLs Part
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} .
    php_value memory_limit 64M
    # Force all pages to go to www.example.com for SEO
    RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    # Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC] 
    # Additional Settings Follow
    ExpiresActive On
    ExpiresByType image/gif A2592000
    ExpiresByType image/jpeg A2592000
    ExpiresByType image/png A2592000
    BrowserMatch "MSIE" brokenvary=1
    BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
    BrowserMatch "Opera" !brokenvary
    SetEnvIf brokenvary 1 force-no-vary


    Adding the "NC" does not work. My setting for FURL Lowercase Aliases is "no" - I think this means aliases are not case sensitive.

    The issue is that I have links for partners that have different capitalizations of urls (ex. /page1.html or /Page1.html) and the wrong one is sent to my default error page.

    Any ideas? Thank you in advance for taking the time to help!
      • 14258
      • 10 Posts
      To be clear, I need the urls to be case insensitive.
        • 33983 ☆ A M B ☆
        • 181 Posts
        I just wrote a plugin for this like 5 minutes ago.

        Create a new plugin, name it(I named it: CaseInsensitiveURI) and then paste the following code in:

        <?php
        // set OnHandleRequest 
        if ($modx->event->name == 'OnHandleRequest') {
            $rAlias = $modx->getOption('request_param_alias', null, 'q');
            if ( isset ($_REQUEST[$rAlias]) ) {
              $_REQUEST[$rAlias] = strtolower($_REQUEST[$rAlias]);
            }
        }
        ?>
        See docs for more info: http://rtfm.modx.com/display/revolution20/Plugins.
        
        
        
          • 33983 ☆ A M B ☆
          • 181 Posts
          Also note that if you use the Freeze URI option it must be lowercase!
            • 14258
            • 10 Posts
            Yahtzee!

            That worked, thank you! For any others who try this make sure you have the OnHandleRequest check box clicked under system events.

            ------------

            One more thing.

            How can we make .../page1 the same as .../page1.html ?

            I tried Content types & erasing the .html extension - this doesn’t solve the problem though. When I removed the .html extension every .html page was simply the name (example: /page1 ) - however if we type in /page1.html we are again taken to the error page as if it doesn’t exist.

              • 22303 MODX Staff
              • 10,725 Posts
              FWIW, you might consider doing this on the OnPageNotFound event to supplement instead of potentially overriding/conflicting with the default MODX routing behavior which is performed after the OnHandleRequest event.
                • 33983 ☆ A M B ☆
                • 181 Posts
                Modify the plugin to have this code:

                <?php
                if ($modx->event->name == 'OnHandleRequest') {
                    $rAlias = $modx->getOption('request_param_alias', null, 'q');
                    if ( isset ($_REQUEST[$rAlias]) ) {
                      $_REQUEST[$rAlias] = strtolower($_REQUEST[$rAlias]);
                    }
                    // allows page and page.html
                    if ( !isset($modx->aliasMap[$_REQUEST[$rAlias]]) && strpos($_REQUEST[$rAlias],'.html') === false ) {
                        // add the .html
                        $_REQUEST[$rAlias] .= '.html';
                    }
                }
                ?>
                
                  • 14258
                  • 10 Posts
                  Thanks! That worked. no longer have to worry about /page.html or just /page


                  I tired only selecting OnPageNotFound however that didn’t work.

                    • 14258
                    • 10 Posts
                    Noticed that with this code my home page will not work.

                    www.example.com shows my default error page. Other than that it works. It this an easy fix?
                      • 33983 ☆ A M B ☆
                      • 181 Posts
                      Try this:

                      <?php
                      // set OnHandleRequest 
                      if ($modx->event->name == 'OnHandleRequest') {
                          $rAlias = $modx->getOption('request_param_alias', null, 'q');
                          if ( isset ($_REQUEST[$rAlias]) ) {
                            $_REQUEST[$rAlias] = strtolower($_REQUEST[$rAlias]);
                          }
                          // allows page and page.html
                          if ( !isset($modx->aliasMap[$_REQUEST[$rAlias]]) && strpos($_REQUEST[$rAlias],'.html') === false && !empty($_REQUEST[$rAlias]) ) {
                              // add the .html
                              $_REQUEST[$rAlias] .= '.html';
                          }
                      }
                      ?>