Redirect sub domain to domain in .htaccessU
-
Hi all,
(Total newbie with fourth post of the last 7 days askin' for help!...sorry!)
I've discovered that we have a lot of URLs indexed with for example:
http://test.betxpert.com/some-odd-url
This gives me duplicate content in the search engines. I have searched the web and i can not find a solution fore redirecting http://test.betxpert.com/some-odd-url to http://www.betxpert.com/some-odd-url. Can anyone help me what to write in the .htaccess file?
Best regards,
Rasmus
-
I managed to fix this, just wanted to post the solution.
For redirecting traffic without "www." to "www.":
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
For redirecting "test." pages to "www." pages:
RewriteCond %{HTTP_HOST} test.domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
Add these lines to .htaccess and all is well
-
Actually, I don't use the subdomain. For some reason we have it on the server. Along with odds.betxpert.com. Again we do not use them.
What would be the best solution?
a) Redirect 301 from the sub to the main domain
b) Simply tell Google through the robots.txt that they are not to index the pages for the subdomains.
As it is now the sub adresses are competitors to the main pages? So I need to lose them?
What would happen if i simply remove the subdomains from the server such that google gets errors? That would be a problem right?
-
The greater question is..do you even want the test subdomain indexed? If that's there for you testing stuff in development, then redirecting is going to mean that you can't test anything.
If that subdomain shouldn't be in the SERPs at all, what about putting a robots.txt on it to exclude it from being indexed, then go verify the subdomain in Google Webmaster Tools where you can then remove the entire subdomain from the index?
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
-
Complete redesign of website and 301 redirects
I did a complete redesign and content change for my website. I have my new webpages indexed but they still haven't replaced the old ones after 1 month. In search results I see both the old ones and the news ones. How long of a delay should I expect (approximately) for the old pages to be replaced by the new ones knowing the entire website was changed. Thank you,
On-Page Optimization | | seoanalytics0 -
How can I redirect anything after the article url to main article?
Hello everyone, When someone visits my websites article like http://www.website.com/article-title/lol , it give to 404 page error. But when someone http://www.website.com/article-title/ , it shows the article. The word "lol" can be changed to anything. I would like that to be redirected to the main article. Example: Someone visits website.com/article-title/lol, they should be redirected to website.com/article-title/ Is it possible to do so? If yes, please tell me how. Note: I'm using WordPress Thank you
On-Page Optimization | | hakhan2011 -
How come my Domain Authority is slower by 2 points today. Did I do something wrong?
Hello. I've bein working hard Seo in the last months, i started testing Moz Pro, found many issues with my website which i fixed. Today was the big day i was going to be crawled again. But to my surprise my Moz Authority went down by two point. Did I do something wrong? I also had page rank 1 now i have cero. I going backwards. Please any help would be apreciated, regards.
On-Page Optimization | | ebest.cl0 -
How long keep 301 redirects?
Our site has been updated twice in the past 6 years with new, better urls. Initially we did 301 redirects 3 years ago for the url redirects. Recently some of those redirected pages have been redirected again. Question: How long before it's time to have the old, original urls removed through Google? And, once that is done, how long to wait before removing the older redirects from the htaccess file? Appreciate any feedback/insights on this matter.
On-Page Optimization | | Manifestation0 -
One question about the domain choice.
Hi guys, I'm an Italian Web marketing and I'm studying SEO since some moths. First, sorry for my bad english.... 🙂 Second, the question: My Italian blog is going really GREAT in terms of popularity and incomes and know I want to bring it in english language with the help of a professional translator. The choice that I have to take is about the future domain of the english blog. My Italian blog has as url mynameandmysurname.net I don't really like to make the english blog appears like myitalianblogurl.net/english because I think it's a little bit confusing and not professional. I have also thought the idea to make a sub domain like blog.myitalianurl.net. What about the WPML plugin? Do you think it's a great choice? I don't like it because it's confusing and it affect my italian blog. Or maybe is it better to create a new branded blog with different domain? It can be an idea but I think that If I chose this way I will lose all my seo efforts of the last years 😄
On-Page Optimization | | Italianseolover0 -
The best way to redirect to www
What is the best way to redirect non www to www. I saw a lot of the solution. is this one ok? RewriteCond %{HTTP_HOST} !^www.seomoz.org [NC] RewriteRule (.*) http://www.seomoz.org/$1 [L,R=301]
On-Page Optimization | | bruki0 -
Disallow a spammed sub-page from robots.txt
Hi, I have a sub-page on my website with a lot of spam links pointing on it. I was wondering if Google will ignore that spam links on my site if i go and hide this page using the robots.txt Does that will get me out of Google's randar on that page or its useless?
On-Page Optimization | | Lakiscy0 -
301 redirect link
Hi, I found some explanations on seomoz about permanently links, but I'm not sure, if I understood right, what to do. Our website has been created with a wrong structure and I have to change the URL of a couple of pages. E. G. http://www.ix-tours.com/Youth/ixdestBrusselYouth.aspx should be changed to http://www.ix-tours.com/DE/Jugend/BruesselJ.aspx to allow search identify it as a german page. What to do? Should I delete all content from the old page and insert the redirect to the knew one? The code as follows has to be inserted in the head section? Thank you for your help Brgds georg
On-Page Optimization | | itmlage0