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. Problemas with my htaccess file

    Problemas with my htaccess file

    On-Page / Site Optimization
    7 2 138
    • 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 two doamins actived which content is the same. Regarding Google some of you guys told me that I wouldn't be penalized but If I wanted to do a redirection 301 it should be done from one domain to the domain which is my main market. And I just did it. But the problem is that although I have made the corresponding modifications in the htaccess file it doesn' work. When I write www.piensapiensa.com goes to piensapiensa.com (as I configured the WMT) and not to www.piensapiensa.es, in which my market is mainly present. Heres the code for the HTACCESS file:

      Options +FollowSymLinks +ExecCGI
      RewriteEngine on
      RewriteCond %{HTTP_HOST} !^www.piensapiensa.es [NC]
      RewriteRule (.*) http://www.piensapiensa.es/$1 [R=301,L]
      <ifmodule mod_rewrite.c="">RewriteEngine On

      # uncomment the following line, if you are having trouble
        # getting no_script_name to work
        #RewriteBase /

      # we skip all files with .something
        #RewriteCond %{REQUEST_URI} ..+$
        #RewriteCond %{REQUEST_URI} !.html$
        #RewriteRule .* - [L]

      # we check if the .html version is here (caching)
        RewriteRule ^$ index.html [QSA]
        RewriteRule ^([^.]+)$ $1.html [QSA]
        RewriteCond %{REQUEST_FILENAME} !-f

      # no, so we redirect to our front web controller
        RewriteRule ^(.*)$ index.php [QSA,L]</ifmodule>

      Thanks in advanced.

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

        HI Juan Miguel, I don't understand well. You want to redirect everything to piensapiensa.com isn't that so?

        But in your htaccess you're saying to redirect the non www version to the www version of piensapiensa.es

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

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

        What you'll need in your domain is a redirect like

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

        and you're done. if you're sharing server config in the same htacces you can put an

        RewriteCond %{HTTP_HOST} piensapiensa.es [NC]

        juanmiguelcr 1 Reply Last reply Reply Quote 1
        • juanmiguelcr
          juanmiguelcr @mememax last edited by

          Thanks mememax for your reply. Sorry 'cause it wasn't  so clear. What I want is to redirect the traffic from www.piensapiensa.com to www.piensapiensa.es where the main market of my client is. Should I use the last configuration you wrote in the post?

          Thanks again.

          mememax 1 Reply Last reply Reply Quote 0
          • mememax
            mememax @juanmiguelcr last edited by

            Ok so if all the url are the same you can redirect the .es domain to the same page in the .com with

            RewriteRule ^(.*) http://www.piensapiensa.com$1 [R=301,L] (I don't remember if you have a / or not in the rewrite base, so if this doesn't work try adding a / before $1)

            If the new site has different pages fro mthe old one and you don't want to maintain them in the new one just redirect everything to the homepage.

            RewriteRule . http://www.piensapiensa.com [R=301,L]

            juanmiguelcr 1 Reply Last reply Reply Quote 0
            • juanmiguelcr
              juanmiguelcr @mememax last edited by

              Thanks mememax. I didn't understand well. I have:

              www.piensapiensa.es (main market)

              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 las three items to redirect to www.piensapiensa.es (unique domain).

              What would be the senteces (exactly) in the htaccess file?

              Thanks in advance

              mememax 1 Reply Last reply Reply Quote 0
              • mememax
                mememax @juanmiguelcr last edited by

                Ok, actually having set up the GWT makes google understand which one is the main address but it is not phisically redirected for the other Search Engines.

                You'll have two different htaccess files. One in the .com site:

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

                if you have the same url structure. If not:

                RewriteEngine On
                RewriteRule . http://www.piensapiensa.com [R=301,L]

                And the other in the .es site:

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

                this will make redirect everything to the www.piensapiensa.es version. HOpe this clarifies you everything. However I really recommend you to have a well trained webmaster doing this for you, because if you don't know how to edit an htaccess you can mess up your whole site.

                juanmiguelcr 1 Reply Last reply Reply Quote 1
                • juanmiguelcr
                  juanmiguelcr @mememax last edited by

                  Thanks mememax. I got it now. The problem is that I have only one htaccess file. www.piensapiensa.es and www.piensapiensa.com (the two domains) show the same web there's only one site, one CMS, Wordpress.

                  Thanks again for your time.

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  • .htaccess Question and Ranking
                    ThomasHarvey
                    ThomasHarvey
                    0
                    2
                    87

                  • Two Robots.txt files
                    TrulyTravel
                    TrulyTravel
                    0
                    5
                    514

                  • Apache .htaccess query string redirects
                    vmialik
                    vmialik
                    0
                    4
                    239

                  • Using a dash or underscores in file names.
                    Martijn_Scheijbeler
                    Martijn_Scheijbeler
                    0
                    3
                    15.9k

                  • How important are image file names
                    jjtech
                    jjtech
                    0
                    5
                    1.3k

                  • Robots file include sitemap
                    yeagerd
                    yeagerd
                    0
                    2
                    180

                  • I have a direct question about file structure.
                    KeriMorgret
                    KeriMorgret
                    0
                    3
                    541

                  • Image files names - should each be different ?
                    lolskizz
                    lolskizz
                    0
                    8
                    922

                  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