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
-
Worth Dropping www. from Domain Name to Shorten URL
The Moz page grader identified several pages where the only problem is the length of the URL, above 75 characters. The site uses uses the www. prefix, and has for years, since 2001. Is it worth dropping the www. and doing a redirect to https://domainname.com to gain the 4 characters
On-Page Optimization | | FatRodent20130 -
How many internal links should a (sub-)page maximal have?
What would the effect of having too much be? Does google stop crawling after a number and punish more internal links?
On-Page Optimization | | brainfruit0 -
New jobboard: Can redirecting folder (site.com/jobboard) to subdomain (jobboard.site.com) hurt SEO?
Hi there, I'm planning to implement a jobboard on my website which needs to be installed on a subdomain (jobboard.site.com) but I'd really like to use site.com/jobboard for promoting this jobboard (jobboard collects external industry jobs). Are there any possible disadvantages when I set up a 301 redirect from jobboard.site.com to site.com/jobboard? Also: What if I want to move this jobboard to a unique domain one day (e.g. jobboard-industry-xy.com), Would that be tricky (as I'd basically have to redirect the folder-to-subdomain redirect to an external domain and therefore get a folder-to-subdomain-to-external-domain redirect...)? Cheers, Thomas
On-Page Optimization | | stl990 -
Boatload of 301 Redirects Question
We have a client that came to us and they recently did a site makeover. Previously they had all their pages in root directory including 75+ spammy article pages. On their makeover, they moved all the article pages into a directory and added 301 redirects. In going over their site we noticed they have redundant articles, like an article on blue-marble-article.htm and blue-marbles-article.htm Playing on singular and plural with dulpicate content for most part with exception to making it plural. If they have 75 articles, Id say 1/3 are actually somewhat original content. I would like to 301 redirect 2/3's of the articles to better re-written article pages but that would add a whole lot more 301 redirects. We would then have a 301 redirect from root directory to article directory, then another 301 redirect from spam article to new re-written article. My question is, would this be too many redirects for googlebot to sort through and would it be too confusing or send bad signals? Or should I create a new directory with all good articles and just redirect the entire old articles directory to the new one? Or just delete the redirects and old spammy directory and let those fall on a 404 error page. Id hate to lose 50-75 pages but I think its in fact those spammy pages that could be why the site fell from top of first page google to third page and now 10th page in a years time. I know, Im confused just typing this out. Hope it makes sense for some good feedback and advise. Thanks.
On-Page Optimization | | anthonytjm0 -
Redirect
Some time ago I have created a category which I have deleted later. Now seomoz is showing me that its not found, obviously...what would be the best practice to redirect this category to a page? I know that with 301, but how, can I do it when I deleted that category:-(
On-Page Optimization | | VillasDiani0 -
Multiple Years Domain Registration
Is there benefit to registering a domain name for multiple years from a SEO standpoint?
On-Page Optimization | | lbohen0 -
How to go after a domain name when the whois info is incorrect.
I found a domain that I'd really like to buy. It's currently active but has just a single image on it (that links to an affiliate product). I'd like to see if the owner would like to sell it to me. But, when I emailed the address that's listed with the whois info it bounced back. Any ideas on how else I can buy this domain?
On-Page Optimization | | MarieHaynes0 -
My Domain Name - short vs relevant
I'm creating a website for my new web design company in Vancouver. I'm looking to target such keywords as "Web Design Vancouver", etc. I have another company with a hyphenated domain name which is terrible when I'm on the phone and my client asks me for my domain (hard to say, always spelling it out). Also I wanted to have a good snappy name for my new business so I found a 6 letter .com and matching .ca for my company. My question is: is it best to use a short domain name or is it better have my keywords in the domain name? eg. xyz.com vs xyzvancouverwebdesign.com Thanks
On-Page Optimization | | VebianWebandMobileDevelopment0