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

    Im having huge trouble understanding how to make SEO friendly urls.

    I’ve seen lots of post around the net with various .htaccess content, but what is the correct one? huh

    My .htaccess looks like this:
    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]


    And in my modx 1.0.4 it’s set to

    Yes
    *Empty*
    .html
    Yes
    Yes
    No
    Yes

    Heeeelp........!!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      With the most common Linux/Apache type platform, the ht.access that comes with MODx can simply be renamed to .htaccess. About the only thing you would need to do is edit the RewriteBase line if MODx is installed in a subdirectory rather than in the web root.

      However, you don’t mention which version of MODx you are using, nor what OS or web server platform you’re working with.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 4078
        • 31 Posts
        I’m using MODX 1.0.4 - I just downloaded it today.

        Im on Win7.. Apache server..

        I just tried changing what you said, still no luck.. Why does it have to be this hard? sad
          • 33337
          • 3,975 Posts
          Do you have mod_rewrite enabled? ..

          What errors exactly you get? If any.
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 4078
            • 31 Posts
            I dont get any errors at all, it’s like it doesnt know .htaccess is there. I did change it to .htaccess in both root and in manager/

            Now this is .htaccess in manager:
            # For unexpected logouts in multi-server/cloud environments see:
            # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
            
            RewriteEngine Off
            
            <IfModule mod_security.c>
            # Turn the filtering engine Off
            SecFilterEngine Off
            </IfModule>


            And the .htaccess in root:
            # 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 modx-test/ # 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]
            
            # For Friendly 
            
            URLs
            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


            I’m sorry if this is not correct, I’m not good at this right now.
              • 33337
              • 3,975 Posts
              Looks like its broken, please copy paste the following, for the root .htaccess

              # 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]
              
              # For Friendly URLs
              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
              
                Zaigham R - MODX Professional | Skype | Email | Twitter

                Digging the interwebs for #MODX gems and bringing it to you. modx.link
                • 4078
                • 31 Posts
                It still doesnt work. In my nav menu, say my "contact" normally has index.php?id=5 but now changes to contact.html when I set SEO Friendly URLS on, but it still does not work.

                I get this message:
                Object not found!
                
                The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
                
                If you think this is a server error, please contact the webmaster.
                
                Error 404
                
                localhost
                08-07-2010 22:35:03
                Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I presume that modx-test is the subdirectory MODx is installed into. That should be
                  RewriteBase /modx-test

                  That file has a lot of places where the lines are broken; this is how the file should actually look.
                  # 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 /modx-test
                  
                  # 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]
                  
                  # For Friendly URLs
                  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
                  

                  The /manager directory doesn’t really need it; there are rules here to exclude the /manager directory from the rewrite process.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 33337
                    • 3,975 Posts
                    [edit] Susan beat me to it! tongue


                    Can you tell me filesystem path and apache root path?

                    eg. c:/apache/root/
                    eg. c:/apache/root/modx

                    If you have it inside /modx, you have to change this line:
                    RewriteBase /
                    

                    to this:
                    RewriteBase /modx
                    
                      Zaigham R - MODX Professional | Skype | Email | Twitter

                      Digging the interwebs for #MODX gems and bringing it to you. modx.link
                      • 4078
                      • 31 Posts
                      Thanks, but it still doesnt work. It can’t find the site.

                      Is it something in the Administration panel I’m doing wrong? undecided