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. On-Page / Site Optimization
    4. Redirection

    Redirection

    On-Page / Site Optimization
    3 3 144
    • 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.
    • juanmiguelcr
      juanmiguelcr last edited by

      Hi all I have these domains active:
      www.piensapiensa.es
      http://piensapiensa.es which redirects to www.piensapiensa.es via webmastertools
      http://piensapiensa.com
      www.piensapiensa.com which redirects to http://piensapiensa.com via webmastertools.
      I want the last three items to redirect to www.piensapiensa.es

      Here is part of the code of the htaccess file that I have until now:
      Options +FollowSymLinks +ExecCGI
      RewriteEngine on
      RewriteCond %{HTTP_HOST} !^www.piensapiensa.es [NC]
      RewriteRule (.*) http://www.piensapiensa.es/$1 [R=301,L]

      Thanks in advanced.

      1 Reply Last reply Reply Quote 0
      • dot-B-dot-B
        dot-B-dot-B last edited by

        In theory I think this should work because because the third line is saying "grab all urls that are not htttp://www.piensapiensa.es"  and then the 4th says to "change to them to htttp://www.piensapiensa.es"

        You have a typo though in line 3 -

        RewriteCond %{HTTP_HOST} !^www.piensapiensa.es [NC] should be

        RewriteCond %{HTTP_HOST} !^www.piensapiensa.es [NC]  (remove the \  between your domain name and the ".es"

        As it is now it is not going to do anything for you until you fix that.

        1 Reply Last reply Reply Quote 1
        • Aleyda
          Aleyda last edited by

          Hi Juan Miguel,

          For the non-www to www redirects, from http://piensapiensa.es to http://www.piensapiensa.es you can use:

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

          On the other hand, to redirect: http://piensapiensa.com and  http://www.piensapiensa.com to http://www.piensapiensa.es you can use:

          RewriteEngine On
          RewriteBase /

          RewriteCond %{HTTP_HOST} ^piensapiensa.com [nc]
          RewriteRule ^(.*)$ http://www.piensapiensa.es/$1 [r=301,nc,L]

          RewriteCond %{HTTP_HOST} ^www.piensapiensa.com [nc]
          RewriteRule ^(.*)$ http://www.piensapiensa.es/$1 [r=301,nc,L]

          Thanks,

          Aleyda

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          • My site auto redirects http to https. This is causing redirect chains. What can I do?
            WebQuest
            WebQuest
            0
            2
            130

          • Domain Redirection
            Roman-Delcarmen
            Roman-Delcarmen
            0
            3
            78

          • To redirect or not to redirect...That is the question
            EGOL
            EGOL
            0
            3
            189

          • Redirect
            VillasDiani
            VillasDiani
            0
            6
            68

          • Temporary Redirects
            AdagioWaterFeatures
            AdagioWaterFeatures
            0
            3
            370

          • Redoing a site - 404 redirect or 301 redirect
            danatanseo
            danatanseo
            0
            3
            536

          • 301 redirect -
            aidanlawlor
            aidanlawlor
            0
            4
            324

          • How do I do a 301 Redirect in IIS 7 from http://www.freightmonster.com/index.html to http://freightmonster.com/index.html when I don't have a physical page to redirect?
            EricaMcGillivray
            EricaMcGillivray
            0
            4
            1.0k

          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