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
-
Canonical cross domain Linkjuice
I know that back few years ago, rel=canonical used on cross-domain was passing link juice. As I've read based on many experts (case studies), the canonical cross-domain was working like implementing a 301. Is it still the case ? Does anyone tried to implement it recently and it worked ?
White Hat / Black Hat SEO | | manoman880 -
Permanently Moving Few High Ranking Pages from One Domain to Another
We are planning to move few high ranking pages permanently (301 Permanent Redirection) to another domain, Currently these pages are getting good traffic from organic search and ranking on top positions in Google search engine result pages. We have few questions in our mind right now, It would be a great help if anyone can answer following questions; Is it possible to move few pages from one domain to another by using 301 Redirection in .htaccess file? Will it have any negative impact on our website's current search engine performance? Will it be considered as a legitimate SEO practice by Google Search Engine? Will Google understand that these pages have been moved permanently to another domain and start showing URL's from the new domain on the same positions where they were ranking before moving to new location?
White Hat / Black Hat SEO | | tigersohelll0 -
Change domains and start over?
We have a fairly new client who has taken part in many questionable SEO technique over the past few years (mainly buying links and directory web pages). In an effort to fix this they hired three separate SEO’s – we are the fourth. Over the past 3 months we have spent lots of time following best practice techniques to clean up and improve their rankings (including link removal requests but not yet disavow), and after some initially positive results, things are looking down again. Given Google’s apparent rolling algorithm updates and the mess we have found, we are wondering if the best option is to change domains and start over (downside is that they are in a highly competitive industry)? My other question pertains to a domain change and if we were to change from a plural to a singular, would that be enough for Google? (e.g from www.domains.com to www.domain.com). The idea is that we start the link building process again – but keep their brand intact. Really appreciate any feedback.
White Hat / Black Hat SEO | | E2E0 -
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 -
Can I 301 redirect old URLs to staging URLs (ex. staging.newdomain.com) for testing?
I will temporarily remove a few pages from my old website and redirect them to a new domain but in staging domain. Once the redirection is successful, I will remove the redirection rules in my .htaccess and get the removed pages back to live. Thanks in advance!
White Hat / Black Hat SEO | | esiow20130 -
Local Listing Question
We have a client that has signed on with a national business network for contractors. This was done without our consent, so I wanted to get everyone's feel on whether or not we should talk them out of continuing this partnership. The example I am showing is not our client, but they are part of this network and have the exact type of setup. Regular website: http://www.palmerheatingandcooling.com
White Hat / Black Hat SEO | | JohnWeb12
Network webpage: http://www.heatingandair.com/annapolis-marlyand Regular Google Plus Local Profile: https://plus.google.com/117245435648294066529/about?hl=en
Network Google Plus Local Profile: https://plus.google.com/112323273882064003718/about?hl=en Here is a local search with both profiles showing up:http://goo.gl/8fxZV
I have attached a screenshot of the results. Is this type of partnership ok in Google's eyes? Is this network listing going to hurt their regular listing in the future? ZGPJfvi0 -
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