The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Redirecting Canonical Hostnames

    Redirecting Canonical Hostnames

    Technical SEO Issues
    3 2 372
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bigrat95
      bigrat95 last edited by

      Hi, I want to rewrite all the url pages of "site.com" to "www.site.com".

      I read the moz redirection article and i concluded that this would be the best approach.

      RewriteCond %{HTTP_HOST} !^www.seomoz.org [NC]
      RewriteRule (.*) http://www.seomoz.org/$1 [L,R=301].

      But i recieved this error:

      Internal Server Error

      The server encountered an internal error or misconfiguration and was unable to complete your request.

      Please contact the server administrator, webmaster@localhost 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.

      I tried this rewrite too...

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

      It worked but it just rewriting my domain** "site.com"** and not all the subs "site.com/fr/example.php" to "www.site.com"

      Why it doesn't work properly, it seem to be easy...

      Could it be a hosting problem?

      Is there another way to do it?

      <address> </address>

      <address> </address>

      <address> </address>

      <address> </address>

      1 Reply Last reply Reply Quote 0
      • WilliamKammer
        WilliamKammer last edited by

        Yours is a little overcomplicated. Give this one a go:

        RewriteCond %{HTTP_HOST} ^example.com$

        RewriteRule (.*) http://www.example.com$1 [R=301,L]

        Also, when you're writing horrid htaccess rules like this, this tool can be helpful: http://www.regexr.com/

        1 Reply Last reply Reply Quote 0
        • bigrat95
          bigrat95 last edited by

          I didn't realise that there was other Htaccess folder in the /en and /fr... But thank alot for the help and I will chek Regexr.com !

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          • Is a canonical tag required for already redirecting URLs?
            nhhernandez
            nhhernandez
            0
            4
            63

          • Change URL or use Canonicals and Redirects?
            LoganRay
            LoganRay
            0
            5
            85

          • Canonical redirects
            socialengaged
            socialengaged
            0
            3
            98

          • Do I need both canonical meta tags AND 301 redirects?
            Dr-Pete
            Dr-Pete
            0
            4
            1.1k

          • Rel=Canonical on a page with 302 redirection existing
            sjcbayona-41218
            sjcbayona-41218
            0
            7
            2.3k

          • Redirect non-www if using canonical url?
            RobertFisher
            RobertFisher
            0
            3
            515

          • Redirect or not to redirect
            AlanMosley
            AlanMosley
            0
            7
            458

          • Permanent 301 redirects vs canonical urls?
            sferrino
            sferrino
            0
            4
            725

          Get started with Moz Pro!

          Unlock the power of advanced SEO tools and data-driven insights.

          Start my free trial
          Products
          • Moz Pro
          • Moz Local
          • Moz API
          • Moz Data
          • STAT
          • Product Updates
          Moz Solutions
          • SMB Solutions
          • Agency Solutions
          • Enterprise Solutions
          • Digital Marketers
          Free SEO Tools
          • Domain Authority Checker
          • Link Explorer
          • Keyword Explorer
          • Competitive Research
          • Brand Authority Checker
          • Local Citation Checker
          • MozBar Extension
          • MozCast
          Resources
          • Blog
          • SEO Learning Center
          • Help Hub
          • Beginner's Guide to SEO
          • How-to Guides
          • Moz Academy
          • API Docs
          About Moz
          • About
          • Team
          • Careers
          • Contact
          Why Moz
          • Case Studies
          • Testimonials
          Get Involved
          • Become an Affiliate
          • MozCon
          • Webinars
          • Practical Marketer Series
          • MozPod
          Connect with us

          Contact the Help team

          Join our newsletter
          Moz logo
          © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
          • Accessibility
          • Terms of Use
          • Privacy