301 domain name URL variants for canonicalization question in htaccess?
-
#1
RewriteCond %{HTTP_HOST} ^xyz.com [NC]
RewriteRule ^(.*)$ http://www.xyz.com/$1 [L,R=301]
What I want to do here is to redirect URLs that have omitted the “www.” prefix to the full “www.xyz.com” home page URL. That means the home page URL http://xyz.com will not resolve on its own, but instead will redirect to http://www.xyz.com (without trailing slash).
#2
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index).(html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index).(html|php|htm)$ http://www.xyz.com/$1 [L,R=301]
What I want to do here is to ensure that any home page URL that includes several versions of explicit page name references, such as default.htm or index.html, will be redirected to the canonical home page URL, http://www.xyz.com (without trailing slash).
Are the rewrite rules correct? Thanks in advance!
-
I've tested both and the logic looks fine.
However, as always with .htaccess changes, I'd recommend testing to verify this has been set up properly once you roll these out (easy enough with a quick ping / page load).
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
-
Does Duplicate Content Actually "Penalize" a Domain?
Hi all, Some co-workers and myself were in a conversation this afternoon regarding if duplicate content actually causes a penalty on your domain. Reference: https://support.google.com/webmasters/answer/66359?hl=en http://searchengineland.com/googles-matt-cutts-duplicate-content-wont-hurt-you-unless-it-is-spammy-167459 Both sources from Google do not say "duplicate content causes a penalty." However, they do allude to spammy content negatively affecting a website. Why it came up: We originally were talking about syndicated content (same content across multiple domains; ex: "5 explanations of bad breath") for the purpose of social media sharing. Imagine if dentists across the nation had access to this piece of content (5 explanations of bad breath) simply for engagement with their audience. They would use this to post on social media & to talk about in the office. But they would not want to rank for that piece of duplicated content. This type of duplicated content would be valuable to dentists in different cities that need engagement with their audience or simply need the content. This is all hypothetical but serious at the same time. I would love some feedback & sourced information / case studies. Is duplicated content actually penalized or will that piece of content just not rank? (feel free to reference that example article as a real world example). **When I say penalized, I mean "the domain is given a negative penalty for showing up in SERPS" - therefore, the website would not rank for "dentists in san francisco, ca". That is my definition of penalty (feel free to correct if you disagree). Thanks all & look forward to a fun, resourceful conversation on duplicate content for the other purposes outside of SEO. Cole
White Hat / Black Hat SEO | | ColeLusby0 -
Acquire domains to boost yours, how to redirect an acquired domain
What is the best way to redirect for best SEO benefits? Examples: glaspunt.nl -> glas.nl fietstassen.eu -> loodgieter.nl Any technical information how to (root) redirect for best SEO practices?
White Hat / Black Hat SEO | | remkoallertz0 -
G.A. question - removing a specific page's data from total site's results?
I hope I can explain this clearly, hang in there! One of the clients of the law firm I work for does some SEO work for the firm and one thing he has been doing is googling a certain keyword over and over again to trick google's auto fill into using that keyword. When he runs his program he generates around 500 hits to one of our attorney's bio pages. This happens once or twice a week, and since I don't consider them real organic traffic it has been really messing up my GA reports. Is there a way to block that landing page from my overall reports? Or is there a better way to deal with the skewed data? Any help or advice is appreciated, I am still so new to SEO I feel like a lot of my questions are obvious, but please go easy on me!
White Hat / Black Hat SEO | | MyOwnSEO0 -
Could lots of links pointed to 301 & 302 redirects be a problem?
Hello, We've got hundreds of links found in screaming frog that are pointing towards 301 & 302 redirects. Could this be hurting rankings? We've got very few 404s. A lot of the problem is breadcrumbs of categories pointing to 302s, but the original category pages that are 302ed are not indexed so we may be OK. We can't change the 302 redirects, it's part of the cart. Could all these non-updated hyperlinks be the cause of continual ranking drop in Google? We've gone from the top 3 to the second page for our main terms. Thanks!
White Hat / Black Hat SEO | | BobGW0 -
Is there any value in "starting from scratch" on a new domain?
Hi, Our ecommerce store - we have had some duplicate content issues and they have been corrected, but of course, Google takes time to pick up on these. Our link profile is very poor, so we wont lose a lot by going to a new domain in that sense. My question is, in what instances is it worthwhile starting under a new domain? And in which not? Presumably you can also 301 the whole site - when is it worth doing this or not? Thanks, Ben
White Hat / Black Hat SEO | | bjs20100 -
302 redirects - redirecting numerous domains into main primary domain
302 Redirects - We are a digital agency carrying out some SEO analysis for a potential client. The client has bought over 150 different domains and redirected (302) them into his main domain. The domains were bought up based on relevant industry keywords and protection. On first instance this seems like a Black hat technique that Google would most definitely punish - buying up domains and redirecting them to main website. Does anyone have any thoughts on this? Thanks...
White Hat / Black Hat SEO | | Seanbain0 -
Google Sitemaps & punishment for bad URLS?
Hoping y'all have some input here. This is along story, but I'll boil it down: Site X bought the url of Site Y. 301 redirects were added to direct traffic (and help transfer linkjuice) from urls in Site X to relevant urls in Site Y, but 2 days before a "change of address" notice was submitted in Google Webmaster Tools, an auto-generating sitemap somehow applied urls from Site Y to the sitemap of Site X, so essentially the sitemap contained urls that were not the url of Site X. Is there any documentation out there that Google would punish Site X for having essentially unrelated urls in its sitemap by downgrading organic search rankings because it may view that mistake as black hat (or otherwise evil) tactics? I suspect this because the site continues to rank well organically in Yahoo & Bing, yet is nonexistent on Google suddenly. Thoughts?
White Hat / Black Hat SEO | | RUNNERagency0 -
Google Bombing For A Specific URL
The term "Beruk" which means "Ape or Monkey" in english brings up this page of wikipedia amongst the first page result: URL: http://en.wikipedia.org/wiki/Khairy_Jamaluddin The page does not contain the word "Beruk". External links to the page do not contact the anchor-text "Beruk" Given the above scenario, how is the page still ranking on first page for this keyword?
White Hat / Black Hat SEO | | rajeevbala0