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 athority for a redirectiones domain
Hi everyone: I create a new version for a website, his DA was 38, but it was redirectioned (with search console and 301 redirection) for a new domain. The website with new domain is working two months ago and still have DA: 1 and PA: 1. How many time take to DA and PA to start to grow up? Thanks for the answers
On-Page Optimization | | diegodiaz850 -
How defined does the anchor text need to be for a domain url?
Ok, I'm looking to clean up my domain with irrelevant Anchor text linking to specific URL's. Whether, it's my root domain or a particular product URL. I'm finding a wide variety of terms (anchor text) pointing to my homepage, category and finally my product pages. Example, the Anchor text "Paragon Print Systems" is pointing to my homepage "barcodefactory.com" does this hurt my homepage enough to either have the link/anchor text removed from linking to my homepage? thanks much!, Warren
On-Page Optimization | | Warren.W0 -
Redirect Code Needed.
Hi, Please help me redirect the following pages in htaccess. https://www.mydomain.com/FolderA/FolderB/number-of-pages.html to **https://www.mydomain.com/FolderA/FolderC/FolderB/number-of-pages.html ** I want to redirect atleast 50 pages like this. Please help Thanks
On-Page Optimization | | Kashif-Amin0 -
To redirect or not to redirect...That is the question
We have old product data that is being updated (approx 30k sku's). Most of the old pages have been indexed and drive the majority of our online sales. But, the updated products have different titles, H1's, etc and have been re-formatted for the better in terms of usability. So, should we redirect thousands of pages to the new pages? Will Google be ok with that?...or should we reformat the current url's with the new data? And, if we reformat current url's with new data...the fear is that the on-page elements that the pages are being pick up for will get wiped out, (be it the H1 in some cases or the title or alt tag for another, etc) because it's simply too much to retain them during the import. Please share
On-Page Optimization | | nisvision0 -
Multiple keywords over multiple domains - am I missing the point?
This I think, is a conceptual question related to Moz/ KeywordTracking in general. Q: What is a "good" way to setup tracking for keywords across many pages, potentially multiple domains? At present I've identified some keywords that are relevant to our products. That leads me to want to track not just for a specific page, but for their rankings across multiple pages, and potentially at least two domains. One site is our main product site, the other a blog/info site. This is I suppose mostly discovery at this point. Working out what, if any, of our pages are ranking for a full set of keywords that we believe are related to our products. It may be that I'm completely missing the point of tracking, that I'm not using it as intended. I want to learn how our pages track currently (for a bunch of keywords), see that change over time as we make changes, and also visualise what we're strong in and what we're not. To me, this would let me see just where the holes are in our SEO easily. The reason I ask is that it seems I have to manually enter a keyword plus a webpage in Moz. Given I've 20-30 keywords I want to track many pages, this is going to take me "quite some time" (tm). Is there a better way to do what I describe here? Am I missing the point of keyword tracking?
On-Page Optimization | | shinywhitebox0 -
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 -
Temperary redirects
I have a problem with temp redirects, I have a dating site and the redirects happen when guests on the site are prompted to purchase a subscription while trying gain access to the sites contents. I was told to change them to 301 redirects but don't know how. any help, thanks guys.
On-Page Optimization | | clickit2getwithit0 -
Hyphens in Domain Name
I have a client who is a business broker. I have just begun working with them, and they are trying to determine the best domain name to use - they have several. business-broker-alabama.com vs businessbrokeralabama.com Which one of these has more value? I know that search engines have somewhat devalued keywords. The first one probably has a little more SEO value, but is going to be a drag in terms of marketing -- saying "business hyphen broker hyphen alabama" is going to get old for them. Thanks!
On-Page Optimization | | csmithal0