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
-
One page with multiple sections - unique URL for each section
Hi All, This is my first time posting to the Moz community, so forgive me if I make any silly mistakes. A little background: I run a website that for a company that makes custom parts out of specialty materials. One of my strategies is to make high quality content about all areas of these specialty materials to attract potential customers - pretty strait-forward stuff. I have always struggled with how to structure my content; from a usability point of view, I like just having one page for each material, with different subsections covering covering different topical areas. Example: for a special metal material I would have one page with subsections about the mechanical properties, thermal properties, available types, common applications, etc. Basically how Wikipedia organizes its content. I do not have a large amount of content for each section, but as a whole it makes one nice cohesive page for each material. I do use H tags to show the specific sections on the page, but I am wondering if it may be better to have one page dedicated to the specific material properties, one page dedicated to specific applications, and one page dedicated to available types. What are the communities thoughts on this? As a user of the website, I would rather have all of the information on a single, well organized page for each material. But what do SEO best practices have to say about this? My last thought would be to create a hybrid website (I don't know the proper term). Have a look at these examples from Time and Quartz. When you are viewing a article, the URL is unique to that page. However, when you scroll to the bottom of the article, you can keep on scrolling into the next article, with a new unique URL - all without clicking through to another page. I could see this technique being ideal for a good web experience while still allowing me to optimize my content for more specific topics/keywords. If I used this technique with the Canonical tag would I then get the best of both worlds? Let me know your thoughts! Thank you for the help!
White Hat / Black Hat SEO | | jaspercurry0 -
Should you include keywords in your domain name to rank well on Google Places?
Is it okay to include keywords in your domain name (as well as business name) to rank well on Google Places? In my opinion, this is very spammy and the sites using this technique will be slapped by Google sooner or later.
White Hat / Black Hat SEO | | thegoatman1 -
Getting a link from an internal page with PR 2 of a domain with PR 5 is how much effective?
My website got a link from an internal page with PR rank of 2 but the domain has the PR rank 5. For example - A domain www.example.com with PR rank 5 and internal page www.example.com/extra/1 PR rank 2. I got a link from the internal page, will I benefit from main domain Page rank 5? Thanks, Sameer
White Hat / Black Hat SEO | | KaylaKerr0 -
Unnatural Link Notification - Third Go Round, specific questions
Hi all, I'm posting what is sure to be a common question, but I can't seem to find much information by searching Q&A over the last month so thought I'd throw this out there. There's a lot of 'what do I do??' questions about 'unnatural link notification', but most of them are from first timers. We're pretty far along in the process and it feels like we're going nowhere, so I was hoping to pick the brains of anyone else who's 'been there'. We have a client that we inherited with an unnatural link profile; they were warned shortly after we took them on (around March was the first warning). We compiled an apologetic letter, specifically identified a previous agency who >was< doing bad things, mentioned things would be different from now on, and provided a list of links we were working on to remove based on WMT and OSE and some other sources. This was submitted in early June. Traffic on the main keyword plummeted; ranking went from top 5 to about mid-page 4. We got hit with that same rash of Unnatural Link warnings on July 23 that everyone else did and after looking around I decided not to respond to those. We got a response to the reinclusion request submitted in June above, saying the site was still violating guidelines. This time I went all out, and provided a Google docs spreadsheet of the over 1,500 links we had removed, listed the other links that had no contact info (not even in WHOIS), listed the links we had emailed/contact formed but got no response, everything. So they responded to that recently, simply saying 'site still violates guidelines' with no other details, and I'm not sure what else I can do. The campaign above was quite an investment of resources and time, but I'm not sure how to most efficiently continue. I promised specific questions, so here they are: Are the link removal services (rmoov, removeem, linkdelete, et al) worth investigating? To remove the 1,500 links I mentioned above I had a full time (low paid) person working for a week. Does Google even reconsider after long engagements like this? Most of what I've read has said that inclusion gets cleared up on the first/second request, and we're at bat for the third now. Due to the lack of feedback I don't know if their opinion is "nope, you just missed some" or "you are so blackhat you shouldn't even bother asking anymore". One of the main link holders is this shady guy who runs literally thousands of directories the client appears in thanks to previous SEO agency, and wants $5 per link he removes. Should I mention this to Google, do they even care? Or is it solely our responsibility? Thanks in advance for any advice;
White Hat / Black Hat SEO | | icecarats0 -
Guest Blogging question
Once your guest posts go live do you do anything to promote them or do you just wait and hope they get indexed? If so what do you do exactly?
White Hat / Black Hat SEO | | RonMedlin0 -
Purchasing an EXPIRING domain with quality related links
I'm about to purchase a domain that has highly trusted links pointed to it. I would like to 301 redirect that domain to point to a brand new domain in the same niche. Some of the links that the expiring domain would take me a long time to obtain so I am thinking to use this method to my advantage. I know that this is not really a legitimate way to go to build backlinks, but surely this is going to give me good serp improvement which is my main concern at the moment. I am going to test this method to see if it benefits me in anyway but I would like some opinions to this please.
White Hat / Black Hat SEO | | umtmedia0 -
How can I make use of multiple domains to aid my SEO efforts?
About an year, the business I work for purchased 20+ domains: sendmoneyfromcanada.com sendmoneyfromaustralia.com sendmoneyfromtheuk.com sendmoneyfromireland.com The list goes on, but you can get the main idea. They thought that the domains can be useful to aid http://www.transfermate.com/ . I can set up a few micro sites on them, but from that point there will be no one to maintain them. And I'm, honestly, not too happy with hosting multiple sites on one IP and having them all link to the flagship. It is spammy and it does not bring any value to end users. I might be missing something, so my question is - Can I use these domains to boost my rankings, while avoiding any shady/spammy techniques? P.S. I had this Idea of auctioning the domains in order to cover for the domain registration fees.
White Hat / Black Hat SEO | | Svetoslav0