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
-
I analysis my domain (http://yourdigibuddy.com/) on moz domain analysis. But there is not data show and show message "No data here". What should I do?
_ I analysis my domain (http://yourdigibuddy.com/) on Moz domain analysis. But there is not data show and show the message "No data here". What should I do?_
On-Page Optimization | | MelissaDooley0 -
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 -
301 redirected Duplicate Content, still showing up as duplicate after new crawl.
We launched a site where key landing pages were not showing up in google. After running the seomoz crawl it returned a lot of duplicate pages which may expalin this. The actual url of the page is /design and it was telling me the following were dupes: /design/family-garden-design
On-Page Optimization | | iterate
/design/small-garden-design
/design/large-rural-garden-design
/Design All of these URL's were in fact pointing to the /design landing page. I 301 redirected all of the pages so they all now resolve to /design After running another crawl the day after doing this it's still showing up as duplicate content on seomoz. Does seomoz evaluate the new changes right away?0 -
Looking to Buy a New Domain for 10 Years
I want to Know, for how much year i should buy a new domain for optimal SEO Results. Should I Buy it for 3 Years, 5 Years or 10 Years
On-Page Optimization | | Ganesh340 -
Google found bad links delete them or 301 redirect?
we went into our google account and saw about 70 bad links that they found on our site. what's the best thing to do, seo-wise: should we go into the pages that have the bad links and delete them from the html code, or re-direct them in our htaccess script?
On-Page Optimization | | DerekM880 -
Domain and subdomain comparison - a deeper look into the subdomain metrics
Hi all, As I'm doing an analysis on our site and our main competitor (both sites are quite big, with active forums), who is much larger than we are, I have found out that : Our site has the strongest domain authority: 34, competitor: 33. Competitor beats us on 6 out of 8 areas in the sub categories for the "domain authority" category We beat our competitor in 8 out of 8 sub categories for the category "sub domain metrics" Now, as the title for this question suggests, I would like to hear what your thoughts is on this. Remember that our competitor is way bigger than us - how can they do so bad on the sub domain metrics, compared to us (and everybody else, I guess)? What are your thoughts on this? Please be aware that the domain shown to the left in the screen shot is our competitor. Thanks a lot - all comments are very much appreciated! yUbrX.png
On-Page Optimization | | MPO0 -
Landing Pages: New Domain or Sub Folder?
I use premise for landing pages. I have some extra domain names that are fantastic in my industry. I'm wondering if I should use those domains for these landing pages? The header, nav, footer, would be the same as my main site, the body and content would be totally different. will google penalize me if I have the same header and footer on a landing page?
On-Page Optimization | | homebizsmart0 -
What's the impact of # in the main domain page?
After a little research I did in the Source Code of the root domain page of seomoz.org and searchenginejournal.com , I found that the first one contains no at all and that the other contains like 10 . I though that the was something relatively important on a web page for on page optimisation. Did I missed something? What's you opinion on the subject? Thanks for your help!
On-Page Optimization | | Louis-Philippe_Dea0