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
-
.htaccess Question and Ranking
I have some basic rules set up in my .htaccess file and just curious as to the implications of them as I seem to have a website ranking very low on Search indexes for no particular reason that I can fathom. My question is a follows I have a htaccess rules set up in my application application that first strips the file suffix and then adds a closing brace for example Rule 1: http://www.domain.com/my_page.php becomes http://www.domain.com/my_page
On-Page Optimization | | ecrmeuro
Rule 2: http://www.domain.com/my_page becomes http://www.domain.com/my_page/ Will this rule expecially Rule 2 effect ranking or will these rule have no adverse affect on the website as my MOZ reports still seem to have pages listed win the Top Pages by PA section without the www? Below is an example of the htacess file. RewriteEngine On Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteCond %{REQUEST_URI} /+[^.]+$
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L] Redirect non-WWW to WWW... RewriteCond %{HTTP_HOST} ^contractor-accounts.co.uk [NC]
RewriteRule ^(.*)$ http://www.contractor-accounts.co.uk/$1 [L,R=301] Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]0 -
Two Robots.txt files
Hi there Can somebody please help me that one of my client site have two robot.txt files (please see below). One txt file is blocked few folders and another one is blocked completely all the Search engines. Our tech team telling that due to some technical reasons they using second one which placed in inside the server and search engines unable to see this file. www.example.co.uk/robots.txt - Blocked few folderswww.example.co.uk/Robots.txt - Blocked all Search Engines I hope someone can give me the help I need in this one. Thanks in advance! Cheers,
On-Page Optimization | | TrulyTravel
Satla0 -
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 -
Disavow Tool Submitting 2nd File
Hi About 2 Months ago I submitted a Disavow File using the Disavow Tool I have collected more links and I am ready to upload a 2nd File, However should I download the previous file in Webmaster Tools (Disavow Tool) and add these new links to that File or if I just upload and override the existing file with this file containing new links only will that be ok. What I dont want to do is do something that removes all the previous findings from the list so that google cannot see them anymore. I guess what I am trying to say is does Google just refer to the live file I am updating / overriding or once I have submitted a file weather i remove it or not will google still have a record of it and be referring to it ? Thanks Adam
On-Page Optimization | | AMG1000 -
How can I fix multiple 404 errors with Wildcard htaccess redirect
Hi all I hope that someone can help.... How can I fix multiple 404 errors with Wildcard htaccess redirect The url in question is: How can I fix multiple 404 errors with Wildcard htaccess redirect http://www.5starweddingdirectory.com/listing/search/Category/luxury_hotels_venues_uk_wedding_venues/exclusive_use_venues/letter/c http://www.5starweddingdirectory.com/listing/location/uk-england/bedfordshire-weddings/franklin-park http://www.5starweddingdirectory.com/deal/location/uk-england/chorley-weddings/curtis-bay etc, going to http://www.5starweddingdirectory.com/business the above is just a few examples, google webmaster is showing over 8.000 404 page not found errors. Thanks in advance.
On-Page Optimization | | Taiger0 -
Is it better to put all your CSS in 1 file or is it no problem to use 10 files or more like on most frameworks?
Is it better to put all your CSS in 1 file or is it no problem to use 10 files or more like on most frameworks?
On-Page Optimization | | conversal0 -
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 -
Duplication About PDF Files on Website
Hello, My site's URL (web address) is: http://www.vostastores.com/ Above is the Our Website URL. We are in the process of Upgrading Our Website and for that we are adding all Details of each and every products. One of the thing that we are planning to do is to get Manufacturer's product PDF files on our Website which the manufacturer already have on their website. So our Question is that Since the manufacturer has the file on their website and we want to add the same on our website, Will be there any Duplication issue? If yes, then please provide us with a Solution by which we can add the same on our website. Thanks & Regards.
On-Page Optimization | | CommercePundit0