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

    I would like to remove the www from my site whilst using ModX, i tried messing with the .htaccess file so i would get http://domain.com/page.htm rather than http://www.domain.com/page.htm but had no luck, can anyone help? I used to have a couple of lines of code in the .htaccess file that did this for me, so if someone entered www.domain.com it would refirect to domain.com, but if i paste this code in now it messes everything up!

    Stupid question i know, just prefer the domain format without the www...

    Many thanks.
    smiley grin

    ModX rocks!
      • 6726
      • 7,075 Posts
      IMHO, every website should work both with or without the www, and it has nothing to do with MODx...

      First way to do it is setting up Apache’s virtualhost,

      Check http://www.webdeveloper.com/management/manage_fix_www.html
      or this : http://aplawrence.com/foo-web/www-domains.html

      Beware that the VirtualHost method though has SEO drawbacks, and it might be better to go with the second method 301 redirect, in .htaccess (code from no-www.org) :

      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
      RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]


      Great article on the subject :
      http://www.mattcutts.com/blog/seo-advice-url-canonicalization/


        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 31337
        • 258 Posts
        David,

        I read the article you recommended -- good stuff, thanks. But I am still confused, why would you *not* just use Apache’s ServerAlias directive to answer to both domain.com and www.domain.com on the same site? How does that mess up SEO stuff?

        Victor
          • 25006
          • 10 Posts
          Thanks for your help.

          Slightly stupid thing on my part, it seemed that whilst using ModX it always redirected to www, but after actually testing it i realised im an idiot tongue

          Your right, i think ill leave it as is - i tried that code you pasted by the way and it messes things up SEO wise, rather than giving the /parent/child.htm i would get something like parent.htm?q=child etc. So removed that code and all is fine, but dont worry about it - now i know using ModX doesnt mean i have to use www only im happy, probobly should of tried it before posting but it just always seemed to be www even if i had entered no www!
            • 23279
            • 1 Posts
            I have a similar problem to this. I initially used my site with URL of http://www.customjavascript.com but I’ve just decided that I’d like to make the URL http://customjavascript.com. I’ve updated my .htaccess file to start with the following:

            RewriteEngine on
            RewriteCond %{HTTP_HOST} ^customjavascript.co.uk$ [OR]
            RewriteCond %{HTTP_HOST} ^www.customjavascript.co.uk$ [OR]
            RewriteCond %{HTTP_HOST} ^www.customjavascript.com$
            RewriteRule ^(.*)$ http://customjavascript.com [R=301,L]
            


            And this works fine. The problem that I am seeing is that the site_url variable (or whatever it is) is still outputting http://www.customjavascript.com (still with "www") and this is messing up inclusions of CSS, JavaScript and image files e.g. [(site_url)]css/common.css. I could probably make these includes by having them as assets but I’d still like to find out how to update the site_url variable.

            How do I update the [(site_url)] to output http://customjavascript.com?

            Thanks.
              • 16885
              • 255 Posts
              Quote from: phobos7 at Nov 25, 2006, 09:30 AM

              How do I update the [(site_url)] to output http://customjavascript.com?

              Thanks.
              Isn’t that simply a matter of editing your config variables? wink

              Quote from: vbrilon at Nov 24, 2006, 10:20 PM

              David,

              I read the article you recommended -- good stuff, thanks. But I am still confused, why would you *not* just use Apache’s ServerAlias directive to answer to both domain.com and www.domain.com on the same site? How does that mess up SEO stuff?

              Victor
              As far as I’ve read, some search engines like Google consider them as separate webpages so your pagerank might increase if you just send all traffic to one url.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                No, the config variables are generated at run-time for each page requested. So if the page is requested as www, then the config variables will be for www.
                  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
                  • 31337
                  • 258 Posts
                  Quote from: Leftblank at Nov 25, 2006, 09:53 AM

                  As far as I’ve read, some search engines like Google consider them as separate webpages so your pagerank might increase if you just send all traffic to one url.

                  Oh I see. So rather then serve up the same content on both URLs, you’re saying it’s better to do a redirect from one to the other?
                    • 12652
                    • 228 Posts
                    From a pure SEO standpoint, yes, you would really be better off to pick the format you want and force everything to it with a 301 redirect....

                    www.somedomain.com
                    somedomain.com

                    These are seen as different so you are potentially splitting traffic.
                      | Identity Developments delivers SEO focused web design and web presence services
                      - it's not about websites, it's about your identity. |
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Another time I’ve seen this make a difference was an ecommerce application, where the SSL certificate was registered to domain.com, so anyone going to the secure part of the checkout with a www.domain.com url would get the browser warnings. Now all the internal links were relative as is usual for MODx, so would have the www depending on how the customer entered the site. And the top Google links were to www.domain.com.
                        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