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
-
Domain Redirection
hi all - question we seem to see people ranking better naturally when they have the seo term in their title. Say we were optimising for "red buses". Our company was called Diamond we are using Diamond.co and have a DA of 32 (Page Title Diamond Red Buses | Bla) Should we buy diamondredbuses.co.uk ? Is it best to continue on our domain and redirect? Or move domains? How much would it affect?
On-Page Optimization | | KellyDSD860 -
To avoid the duplicate content issue I have created new urls for that specific site I am posting to and redirecting that url to the original on my site. Is this the right way to do it?
I am trying to avoid the duplicate content issue by creating new urls and redirecting them to the original url. Is this the proper way of going about it?
On-Page Optimization | | yagobi210 -
One Main Brand Domain - One EMD which Ranks Better
Hello SEO MOZers! We have one one main ecommerce site and I have just discovered we have an EMD sitting on a .co.uk, for one of our premium product ranges, and it actually outranks our main website. It appears on page one. My question is how do I handle the EMD? I don't want to start building authority to this site, as we are currently developing the main brand site, however I can't ignore that it is ranking. There is relatively little content. There are links on the page (it's only one page) that go through to the product section on the main site. But should I 301 redirect it? What would be your advise? I want to capitalise on any traffic we could benefit from, and ultimately I want the main site to rank better for this product's keywords. Any help would much appreciated.
On-Page Optimization | | CarlaAction1 -
Redirect both / and non-/ URLs?
I am doing SEO on WP site. Due to some duplicate pages (rel canonical was done before) I am doing 301 redirects at the moment. And I wonder if I need to redirect both links w/ and w/o trailing slash. Default is non www, w/o trailing slash. Like there is .com/category/news but there is same page linked in .com/news (well it works when permalink structure is set to /%category%/%postname% and returns 404 error when structure is set to /%postname%).
On-Page Optimization | | OVJ
I redirected .lt/naujienos to .lt/category/naujienos. Should I also redirect .lt/naujienos/ (with trailing slash)? There's absolutely no problem redirecting this, but there are some more pages which I want to edit their URLs and I wonder If I should do both redirects from links /w and w/o slash?1 -
Can a country level domain perform well in international SEO if all the targeted keywords are related to that country domain?
Hi fellow Mozers, I am doing international SEO on Google US, UK, UAE and Saudi Arabia. All my targeted keywords have my country name in it, for example, export companies in France, best import companies in France and so on. Finally, my website has a country level domain i.e. www.xyz.co.fr _Hence, my questions are: _ 1. Is it good have a country level domain in this case or should I go TLDs? 2. Should my Google Plus page be a local business page or company page from SEO perspective? I have more than 10000 users who have +1 my website. _Thanks in advance. _
On-Page Optimization | | Abhi81870 -
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 -
Making best use of keyword phrase domain url
Hi everyone Our industry has a particular keyword phrase that is very popular. We currently own this as a domain name. How can we make use of this to our main websites advantage?
On-Page Optimization | | LadyApollo0 -
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