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
-
Is new domian redirection to old domain make risk for my site ?
i have site with Da about 30 and i have many project on it if i register a domain for each project and after that redirect to my site is that bad for my site and my site seo ? for ex: my project is : mysite.com/helloword i register helloworld.com or domain like that helllo-world.com and redirctet to mysite.com/helloworld
White Hat / Black Hat SEO | | MidnightShop791 -
What to do with internal spam url's google indexed?
I am in SEO for years but never met this problem. I have client who's web page was hacked and there was posted many, hundreds of links, These links has been indexed by google. Actually these links are not in comments but normal external urls's. See picture. What is the best way to remove them? use google disavow tool or just redirect them to some page? The web page is new, but ranks good on google and has domain authority 24. I think that these spam url's improved rankings too 🙂 What would be the best strategy to solve this. Thanks. k9Bviox
White Hat / Black Hat SEO | | AndrisZigurs0 -
Scraped site, hijacked searches for business name.
Hello, I have a site that was scraped (possibly by a competitor's seo company), who then built links to the duplicate site. When people do a search for the name of the business the scraped site is all that comes up along with the usual third-party sites. They seem to take the site down and put it back up every couple of weeks to maintain the rankings in Google. Has anyone ever dealt with something like this? Any advice or recommendations would be appreciated. Search: LIC Dental Associates Scraped site: old-farmshow.net Legit site: licdentalassociates.com Thanks, Emery
White Hat / Black Hat SEO | | tntdental1 -
Should I 301 redirect my old site are just add a link to my new site
I used to offer design and web services on a site that is current blank (no content, no links). My questions is should I add a little bit of content, maybe a brief explanation with a link to my new site. Or should I just add 301 redirect. This is purely a question of what is better for SEO and ranking for my new site (not a branding question).
White Hat / Black Hat SEO | | Tyrell0 -
How to resolve - Googlebot found an extremely high number of URLs
Hi, We got this message from Google Webmaster “Googlebot found an extremely high number of URLs on your site”. The sample URLs provided by Google are all either noindex or have a canonical. http://www.myntra.com/nike-stylish-show-caps-sweaters http://www.myntra.com/backpacks/f-gear/f-gear-unisex-black-&-purple-calvin-backpack/162453/buy?src=tn&nav_id=541 http://www.myntra.com/kurtas/alma/alma-women-blue-floral-printed-kurta/85178/buy?nav_id=625 Also we have specified the parameters on these URLs as representative URL in Google Webmaster - URL parameters. Your comments on how to resolve this issue will be appreciated. Thank You Kaushal Thakkar
White Hat / Black Hat SEO | | Myntra0 -
Solved PayDay hack - but SERPs show URLs - what should I do?
We had the PayDay hack - and solved it completely. The problem is - the SERPs have over 3,000 URLs pointing to 404 on our website all of which have urls that are like this: <cite>www.onssi.com/2012/2/post1639/payday-loan-companies-us</cite> What should I do? Should I disavow every one of the 3,000? No Follow?
White Hat / Black Hat SEO | | Ocularis0 -
Adding Domain Names
Hi all, I am pretty new to SEO but i wanted to check out an idea with you guys, I have a business that is called Totaldriveways and the URL is www.totaldrivewaysne.co.uk Although Driveways is a big part of what we do, we are also heavily involved in other services to do with landscaping. The idea ive got is to brand each service with the "Total" for eample Total Driveways is a reconisgened name in my area and i would like to expand that into Total Patios Total Artificial Grass Total Driveway cleaning so each page and service come under a similar brand, my question is is it worth buying these domains also and directing them at the specific pages that they are relevant to, these domains are obviously keyword rich and am guessing will create extra traffic, but will i be penalised at all by google etc. I know this is probably simple stuff to alot of you's but i have no idea Thanks John
White Hat / Black Hat SEO | | totaldriveways0 -
Link Farms and The Relationship between 2 domain with a 301 Redirect
I have an interesting scenario: Domain A was worked on by a disreputable SEO company off shore. The owner of Domain A came to me for my assistance and evaluation on how the off shore company was doing. I concluded that he should terminate the relationship immediately. One of the bad things they did was register Domain A with a LOT of link farms. I started working on a new site that eventually we decided to go with Domain B (a better, but totally related domain name to Domain A). I added a nice new site and had my client write clean, relevant information for it. We've done all legitimate, above ground by-google's-recommendation SEO for Domain B. I have a series of 301 redirects from Domain A to Domain B. Since April 24th, organic search results have plummeted. I see many incoming links via Webmaster Tools as the massive link farms, but those link farms have Domain A in their databases, not Domain B. My question: is Domain B inheriting the link juice from Domain A insofar as the incoming links are showing up in Webmaster Tools as directly related to Domain A? Should I sever the ties with Domain A altogether? Thanks.
White Hat / Black Hat SEO | | KateZDCA1