We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31902
    • 342 Posts
    I have a situation where I’m in the process of building a site. The site, as yet, does not have a domain name pointing to it (will later and will have a .com TLD). Right now, the site is online, but is using an ip type of address to access (http://XX.XXX.XXX.XXX/~client/index.php).

    When I followed the tutorial on this page: http://modxcms.com/forums/index.php?topic=42338.20 to create friendly URLs I was unsuccessful, resulting in error messages...the site was essentially down. The only thing I could think of was the use of the above type of address in the .htaccess file instead of a domain which had a TLD in it.

    Does the .htaccess file need to have a full domain name in order for it to work? If not, what is the procedure to do so?

    Thanks in advance.

    PS: apologies for this post... it originally appeared somewhere within the above tutorial but there were no responses at that time. I do need some advice, though. Thank you.
      • 26016
      • 561 Posts
      Hi,
      I can see why you didn’t get an answer. More details are needed. You didn’t leave a link. Even if you don’t do that, you need at least an error message. We also don’t know if you’re using Revo or Evo. Finally, that’s not really a tutorial.

      This is more of a tutorial, at least for Revo.
      http://rtfm.modx.com/display/revolution20/Using+Friendly+URLs

      I’ll take a quick shot at it anyway, because being on forums, being a psychic has become a requirement.

      I do FURL’s on this sort of temp address frequently. (oh, and we also don’t know a single thing about your hosting... I hope you’re getting the message here) Depending on how your server is set up, it may be easy to fix.

      In the hosting I typically run into, it’s as simple as changing the RewriteBase in .htaccess. If your site were on my hosting, you would simply have this as your RewriteBase:

      /~client/
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 22019
        • 390 Posts
        I was having a similar issue (all my other Revo sites are either URL or subdomain-based, so I was a little stumped) and have edited the RewriteBase rule to include the ’username’ directory.

        I don’t understand why it’s needed though - isn’t that what the base tag is there for? Similarly, MODX knows where the start directory is, otherwise it wouldn’t be able to preview the index page. huh

        Anyway - it works. I’ve also added a site_url and http_host system setting, as that seemed to be necessary for all my context-based sites (but not sure what, if anything they’re adding). When I was poking around I noticed that my config.inc.php has set all the *_url settings as this:
        $modx_connectors_url= '/~user/connectors/';
        $modx_base_url= '/~user/';


        etc. Do I have to go in and edit that once the domain is switched to this IP address? I’m assuming MODX won’t do this automatically. I have just checked and another account I’ve set up on the same reseller domain doesn’t have /~user/ urls.
          Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
          • 26016
          • 561 Posts
          Odeclass,
          Good points. I don’t know the details, because I’m not a server guy, but essentially from a server perspective you might have lots of sites at one IP like this:

          1.22.33.44/~first/
          1.22.33.44/~second/
          1.22.33.44/~third/
          1.22.33.44/~fourth/

          So if you don’t give a specific RewriteBase, each site’s Base URL will default to 1.22.33.44, and that may not point at the site you want.

          And yes, if you’re doing FURL’s using the funky RewriteBase in testing, when you go live with a real domain, you’ll probably need to change the RewriteBase back to just "/". You’ll know that when suddenly your links no longer work.

          I only know this from having done troubleshooting on the various hosts I’ve used. From a server perspective, I’m sure the server admin has all sorts of tricks they can do do make this work in different ways, and they could elaborate upon and correct what I’ve said.

          One bummer about Revo is that making a site live is slightly more of a pain then Evo (which is pretty much a cakewalk), but it’s not too bad.

          Dave
            MODx and Wordpress development
            Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
            • 31902
            • 342 Posts
            Quote from: samba at Mar 21, 2011, 04:53 PM

            Hi,
            I can see why you didn’t get an answer. More details are needed. You didn’t leave a link. Even if you don’t do that, you need at least an error message. We also don’t know if you’re using Revo or Evo. Finally, that’s not really a tutorial ... being a psychic has become a requirement... (oh, and we also don’t know a single thing about your hosting... I hope you’re getting the message here)...

            Thank you all for responding. Yes, samba, consider me spanked. rolleyes

            Anyway, I’m running Revo ModX 2.0.6 on PHP v 5.2.10., Apache 2.0.

            However, I’ve noticed the same problem, and error message, on another site I’m building (Revo 2.0.8. on same server) that has an actual domain name pointing to it, therefore I now believe my problem is not I.P./domain name related anymore.

            In the control panel, I did set the system settings to:

            Use Friendly URLs ’Yes’
            Use Friendly Alias Path ’Yes’

            Each of the resources have a Resource Alias added to it.

            My .htaccess file contains this:

            # Friendly URLs Part
            RewriteEngine On
            RewriteBase /
            RewriteCond %{HTTP_HOST} .
            # Force all pages to go to www.domain.com for SEO
            RewriteCond %{HTTP_HOST} !^www\.(my_domain_added_here)\.com [NC]
            RewriteRule (.*) http://www.(my_domain_added_here).com/$1 [R=301,L]
            # Friendly URLs
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
            # 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



            The error message I’m getting is:

            Internal Server Error
            
            The server encountered an internal error or misconfiguration and was unable to complete your request.
            
            Please contact the server administrator, webmaster@(my_domain).com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
            
            More information about this error may be available in the server error log.
            
            Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
            Apache/2 Server at www.(my_domain).com Port 80


            In the resulting pages with the error messages, in the address bar, I can see where ModX has added the alias to the address.

            Since I get the error message when I upload the .htaccess file, I’m sure that that is where I’ve botched the thing. It goes away when I delete the file off the server.

            BTW: I’ve been uploading the .htaccess file to the root of the site, at the same level as the index.php file. I assume that is correct?

            So, what the heck am I doing wrong? I’m not a server guy, so please be gentle.
              • 26016
              • 561 Posts
              Ah!
              That’s more like it. Sorry to haze you there. I’ll assume the the "my.domain" part is correct in your real .htaccess file.

              Did you actually look at your server logs as the error suggested? That’s usually quite helpful.

              It could easily be an error in your .htaccess file, which is getting a little above my paygrade. As for me, I never use those extra directives at the end... you could try commenting those out just to rule them out. I’ll assume that you didn’t make a typo in the "force WWW" bit.

              You could also try this above your RewriteBase line. Many servers have this turned on by default, others do not:
              Options +FollowSymlinks

              That’s a long shot, I figure.

              I think it would be worth discussing with your host tech support, and see if mod_rewrite is correctly operating. Maybe server experts will have further suggestions.

              Finally, if you’re using alias paths, you’ll want to make sure you have Base Href in your templates, but lacking that would tend to give a 404 rather than a 500 error, I think.

              Cheers
                MODx and Wordpress development
                Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                • 31902
                • 342 Posts
                Quote from: samba at Mar 23, 2011, 11:31 AM

                ...As for me, I never use those extra directives at the end... you could try commenting those out just to rule them out...

                That part was the key, me thinks! I edited the .htaccess to comment out certain things, making it look like:

                # Friendly URLs Part
                RewriteEngine On
                RewriteBase /
                # Force all pages to go to www.domain.com for SEO
                RewriteCond %{HTTP_HOST} !^www\.(my_domain_added_here)\.com [NC]
                RewriteRule (.*) http://www.(my_domain_added_here).com/$1 [R=301,L]
                # Friendly URLs
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                # 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


                ...And it worked. Obviously, the next step is to just delete the parts I don’t need.

                Thanks, samba! You can haze me anytime. laugh
                  • 31902
                  • 342 Posts

                  Taking this solution another step further regarding the temporarily IP addressed site, I modified my .htaccess for that to read like this:

                  # Friendly URLs Part
                  RewriteEngine On
                  RewriteBase /~client/
                  RewriteCond %{HTTP_HOST} .
                  # Force all pages to go to www.domain.com for SEO
                  RewriteCond %{HTTP_HOST} !^XX.XXX.XX.XXX[NC]
                  RewriteRule (.*) XX.XXX.XX.XXX/$1 [R=301,L]
                  # Friendly URLs
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                  # 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


                  And that worked, too. Again, I assume you can delete the commented stuff out if you want.

                  Again, thanks to samba to get me in the zone again.
                    • 26016
                    • 561 Posts
                    Waizen,
                    Very glad to hear that!

                    It’s pleasing to get server stuff right even though really I’m much more of a CSS guy. It comes from having been faced with so many web hosts, some quite arcane. I just did my first site on a Windows server, which I generally avoid like the plague, but I’ve got a good helper there, so it’s running smoothly.

                    Cheers, D
                      MODx and Wordpress development
                      Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
                      • 37913
                      • 9 Posts
                      Samba - thank you so much for this post. You've just ended hours of my searching to fix a FURL problem. Thank you!

                      Quote from: samba at Mar 21, 2011, 04:53 PM
                      Hi,
                      I can see why you didn't get an answer.  More details are needed.  You didn't leave a link.  Even if you don't do that, you need at least an error message.  We also don't know if you're using Revo or Evo.  Finally, that's not really a tutorial. 

                      This is more of a tutorial, at least for Revo.
                      http://rtfm.modx.com/display/revolution20/Using+Friendly+URLs

                      I'll take a quick shot at it anyway, because being on forums, being a psychic has become a requirement. 

                      I do FURL's on this sort of temp address frequently.  (oh, and we also don't know a single thing about your hosting... I hope you're getting the message here)  Depending on how your server is set up, it may be easy to fix. 

                      In the hosting I typically run into, it's as simple as changing the RewriteBase in .htaccess.  If your site were on my hosting, you would simply have this as your RewriteBase:

                      /~client/