We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3288
    • 12 Posts
    I’m trying to set up my first MODx site and I can’t seem to get mod_rewrite to work.

    When I go into the manager and select Reports->System Info ... mod_rewrite is listed as a loaded module.

    I’m sure it’s something simple, either in the httpd.conf file or the .htaccess file but I’m feeling a bit out of my comfort zone and not wanting to break things.

    Any suggestions?

    Thanks.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Have you

      1. turned on Friendly URLs in the Configuration?
      2. renamed the ht.access file to .htaccess?
      3. if your MODx installation is not in the root of your webserver (i.e. public_html/ or htdocs/) have you edited the .htaccess file to set the rewrite_base to the directory your installation is in? For example
      RewriteBase /modx
        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
        • 3288
        • 12 Posts
        Yes, yes, and no previously but now yes.

        So thanks for pointing out the base URL problem ... but it’s still not working.

        My Configuration settings are: (on the Friendly URL tab)

        Use FriendlyURLS - Yes
        Friendly URL Prefix - blank
        Friendly URL Suffix - .html
        Use Friendly URL aliases - Yes
        Use Friendly URL alias path - No
        Allow duplicate URL aliases - No
        Automatically generate URL alias - Yes

        I get the sense though that the system is supposed to automatically generate a page or something ... either that or mod_rewrite still isn’t working ...

        And I’m at a bit of a loss where to look for a solution.

        Thanks for your help.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          What is happening? Are you getting the original index.php?id=xx links in your menu? Try clearing the site cache; cached pages will still have the old menus from before turning on FURLs.
            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
            • 3288
            • 12 Posts
            No I’m getting page not found errors with the full alias calculated (eg. contact-us.html)

            Which is why I’m thinking that mod_rewrite isn’t working
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Do you have another .htaccess file in the web root? Although that should cause a 500 error if you have two .htaccess files turning on the rewrite engine.
                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
                • 3288
                • 12 Posts
                Nope ... no second .htaccess file.

                I did have AllowOveride None set in my httpd.conf file ... which has now been changed and hasn’t solved the problem.

                I’m sure this is going to be simple and I’m going to kick myself ... but it’s frustrating right now.

                I’m running PHP 5.1.6 (in case that matters) on CentOS (64 bit)

                The error in my browser is:


                Not Found

                The requested URL /who-we-are.html was not found on this server.



                In the error log I get:

                [Sat Dec 05 20:48:11 2009] [error] [client 24.72.13.25] script ’/home/mydomain/who-we-are.html’ not found or unable to stat, referer: http://www.mydomain.net/

                And as soon as I turn friendly URLs off ... the site works fine again.

                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  That doesn’t look right; it looks like it’s trying to access from the root of your file system rather than your web root. Can you post your .htaccess file?
                    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
                    • 3288
                    • 12 Posts
                    # 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 /home/mydomain

                    # 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 from rewrite rules
                    RewriteRule ^(manager|assets) - [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
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      There’s your problem. The RewriteBase is from the web root; usually that’s public_html or htdocs or www. For example, for my development installations on my Mac, I have them all in subdirectories under the Applications/MAMP/htdocs directory, so one example is
                      RewriteBase /templates

                      and another is
                      RewriteBase /1.1

                        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