Problemas with my htaccess file
-
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.
-
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.
-
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.
-
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
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
-
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]
-
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.
-
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]
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
What is robots.txt file issue?
I hope you are well. Mostly moz send me a notification that your website can,t be crawled and it says me o check robots.txt file. Now the Question is how can solve this problem and what should I write in robots.txt file? Here is my website. https://www.myqurantutor.com/ need your help brohers.... and Thanks in advance
On-Page Optimization | | matee.usman0 -
Htaccess redirect, from /year/month to /blog
I am trying to make some redirects so we don't lose that SEO juice. I am trying to move our blog structure from:
On-Page Optimization | | opiates
http://www.domain.com/2015/09/title-of-blog to:
http://www.domain.com/blog/title-of-blog I need to do redirects in htaccess from the old structure to the new structure but I can't seem to get it working properly. Here is what I have thus far. <code>RewriteEngine on RewriteBase / RewriteRule ^(.0-9)\/^(.0-9)\$ $1/ [R=301,L]</code> Any suggestions?0 -
Apache .htaccess query string redirects
With regular redirect(s) the following URLs did not work, any ideas for the .htaccess code to make this work? http://www.domain.com/?view=featured redirect to http://www.domain.com/ http://www.domain.com/contact-us.html?view=message&layout=message&pf=1&redirect_on_success= to http://www.domain.com/contact-us.html and http://www.domain.com/login.html?return=aW5kZXgucGhwP29wdGlvbj1jb21fcGhvY2Fkb3dubG9hZCZ2aWV3PWNhdGVnb3J5JmlkPTEyOmNvbWJpbmUtZXZhbHVhdGlvbiZJdGVtaWQ9NzM4 to http://www.domain.com/login.htm Thanks guys! 🙂
On-Page Optimization | | vmialik0 -
Image File Names for eCommerce?
Hi everyone! I'm wondering about naming my product photo file names for an E-Commerce site. Let's say I say have product named Abe Lincoln in the **Print **category for sale with 4 images, relatively similar but from different views for example.Could I name them as follows? 1) abe-lincoln-print.jpg 2) abe-lincoln-print-side-view.jpg 3) abe-lincoln-print-close-up.jpg 4) abe-lincoln-print-font-view.jpg Or is that too many keywords for the page? Should I be worried about keyword stuffing? Plus once I add in title and alt tags and descriptions this could also increase the keyword count for "abe lincoln print"?
On-Page Optimization | | TheFlyingSweetPotato0 -
.htaccess file uploaded, website won't load
I uploaded the .htaccess file with the below, and now my website won't load at all? Then I deleted the htaccess file and it still won't load? But then it would load on my phone when I took it down, not on chrome, or explorer? Then I put it back up and looked again on my phone, wouldn't load on phone. Then deleted file and it still won't load on my phone? What is going on? RewriteEngine on
On-Page Optimization | | dwebb007
RewriteCond %{HTTP_HOST} !^http://freightetc.com$
RewriteRule ^(.)$ http://www.freightetc.com/$1 [R=301]
RewriteCond %{THE_REQUEST} ^./index.php
RewriteRule ^(.*)index.php$ http://www.freightetc.com/$1 [R=301]0 -
How important are image file names
Hi, How important do you think the image file names are for image search?
On-Page Optimization | | jjtech
I know it used to be the best practice a while ago but is it still important? Thanks in advance, JJ0 -
When You Add a Robots.txt file to a website to block certain URLs, do they disappear from Google's index?
I have seen several websites recently that have have far too many webpages indexed by Google, because for each blog post they publish, Google might index the following: www.mywebsite.com/blog/title-of-post www.mywebsite.com/blog/tag/tag1 www.mywebsite.com/blog/tag/tag2 www.mywebsite.com/blog/category/categoryA etc My question is: if you add a robots.txt file that tells Google NOT to index pages in the "tag" and "category" folder, does that mean that the previously indexed pages will eventually disappear from Google's index? Or does it just mean that newly created pages won't get added to the index? Or does it mean nothing at all? thanks for any insight!
On-Page Optimization | | williammarlow0 -
Is it redundant to include a redirect to my canonical domain (www) in my .htaccess file since I already have the correct rel="canonical" in my header?
I've been reading the benefits of each practice, but not found anyone mentioning whether it's really necessary to do both? Personally I try to stay clear of .htaccess rewrites unless it's absolutely necessary, since because I've read they can slow down a website.
On-Page Optimization | | HOPdigital0