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

    Read all the post about this and none of them are working for me, this should be quite simple for someone with .htaccess RewriteRules knowledge.

    I have a page pulling database results in a query string like so:

    /results.html?id=122218880&category=CatName

    I am trying to mod the .htaccess to make the query string more SEO friendly, something like:

    results/CatName/122218880 or whatever. However nothing I try is working at all!

    for example:

    # Results rule #
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^results/(.*)/$ index.php?q=results&id=$1 [L]
    
    
    # The MODx Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    


    or

    RewriteRule ^results/(.*).html results.html?id=$0 [L,QSA]
    
    
    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    


    Are doing nothing! I don't care about the exact URL displayed at this point, I just want to be able to get the RewriteRules working so I can mod in the future. I read and tried these posts in may different variations to no avail:

    https://forums.modx.com/index.php?topic=37334.0

    https://forums.modx.com/index.php?topic=25846.0

    http://ttyl.modx.com/thread/?thread=33699.&i=1&page=1


    Please help! Not sure if there are some other settings I need to change? I am using the correct .htaccess file.

    Thanks

    Shaun

      • 34084 ☆ A M B ☆
      • 756 Posts
      Just a few things to validate before hand;

      a. you have Friendly URL's turned on (good to check basic mod_rewrite)
      b. you are using Apache web server

      To support the strucutre: /results/CatName/122218880
      RewriteRule ^results/([A-Za-z]+)/([0-9]+)/?$ index.php?q=results&id=$2&category=$1 [NC,L]


      Can you provide us with the example of what happens when you enter the URL as intended in SEO format.

      Cheers
        Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
        Visit CharlesMx.com for latest news and status updates.
        • 26951
        • 41 Posts
        Hi Charless

        Yes Friendly URL's are producing results.html, and on Apache web server of course.

        When using your code sample above the page is resolving to:

        www.example.com/results.html?id=122218886&category=Finance%20General fine but not rewriting the intended part.

        If I manually enter the URL as intended it just 404's. It's as if it's completely ignoring the rule, however after researching this (all night!) I have got the "L" operator in the correct place to process that RewruteRule last.

        Here is most of the .htaccess file, perhaps this will shed more light?

        # For full documentation and other suggested options, please see
        # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
        # including for unexpected logouts in multi-server/cloud environments
        # and especially for the first three commented out rules
        
        #php_flag register_globals Off
        #AddDefaultCharset utf-8
        #php_value date.timezone Europe/Moscow
        
        Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /
        
        
        # Fix Apache internal dummy connections from breaking [(site_url)] cache
        RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
        RewriteRule .* - [F,L]
        
        # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
        #RewriteCond %{HTTP_HOST} .
        RewriteCond %{HTTP_HOST} !^www\.EXAMPLE.com [NC]
        RewriteRule (.*) http://www.EXAMPLE.com/$1 [R=301,L]
        
        # Exclude /assets and /manager directories and images from rewrite rules
        RewriteRule ^(manager|assets)/*$ - [L]
        RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
        
        
        # Results rule #
        
        RewriteRule ^results/([A-Za-z]+)/([0-9]+)/?$ index.php?q=results&id=$2&category=$1 [NC,L]
        
        # The MODx Friendly URLs part
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
        
        
        
        
        # Reduce server overhead by enabling output compression if supported.
        #php_flag zlib.output_compression On
        #php_value zlib.output_compression_level 5
        
        ## EXPIRES CACHING ##
        <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/jpg "access plus 1 year"
        ExpiresByType image/jpeg "access plus 1 year"
        ExpiresByType image/gif "access plus 1 year"
        ExpiresByType image/png "access plus 1 year"
        ExpiresByType text/css "access plus 1 month"
        ExpiresByType application/pdf "access plus 1 month"
        ExpiresByType text/x-javascript "access plus 1 month"
        ExpiresByType text/javascript "access 1 hour"
        ExpiresByType application/x-shockwave-flash "access plus 1 month"
        ExpiresByType image/x-icon "access 1 year"
        ExpiresByType text/html "access plus 1 second"
        ExpiresDefault "access plus 1 week"
        </IfModule>



        EXAMPLE.com is my url changed.

        Thanks for any more help you can give. [ed. note: shaundiamonds last edited this post 15 years, 2 months ago.]
          • 34084 ☆ A M B ☆
          • 756 Posts
          try moving it up just after your current
          # Fix Apache

          rewrite rule

          then if you are still not getting the desired results change the results Rewrite rule flags to:
          [NC,R,L]


          this will at least let you see what is going on in the browser location(address) bar

          hope that helps
            Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
            Visit CharlesMx.com for latest news and status updates.
            • 26951
            • 41 Posts
            No difference at all with:

            # Fix Apache internal dummy connections from breaking [(site_url)] cache
            RewriteRule ^results/([A-Za-z]+)/([0-9]+)/?$ index.php?q=results&id=$2&category=$1 [NC,R,L]
            RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
            RewriteRule .* - [F,L]
            
            # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
            #RewriteCond %{HTTP_HOST} .
            RewriteCond %{HTTP_HOST} !^www\.EXAMPLE.com [NC]
            RewriteRule (.*) http://www.EXAMPLE.com/$1 [R=301,L]
            
            # Exclude /assets and /manager directories and images from rewrite rules
            RewriteRule ^(manager|assets)/*$ - [L]
            RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
            
            
            # Results rule #
            
            
            
            
            
            # The MODx Friendly URLs part
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [QSA,L]
            
              • 34084 ☆ A M B ☆
              • 756 Posts
              anyway you'd be able to provide me with ftp access to review the manager?

              cheers
                Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
                Visit CharlesMx.com for latest news and status updates.