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
-
New Software Requires us to redirect a sub domain to another IP Address.
I operate a local print and direct mail company located in Houston called Catdi Printing (www.catdi.com)We do very well with our local rankings and rank 1 or 2 in our main keywords ( direct mail Houston & eddm Houston ) We are looking to upgrade our online quoting and ordering system. The software is very expensive and the only way we can incorporate this new system is create on our end a new subdomain (printing.catdi.com) and redirect it to an ip thats with their server. Their server is located in Californiaa and might even be hosted by Google but im not certain on this point. Our current host provider is Hostgator and they are based in Houston so im not this provides any benefit. I guess my main question is will Google look at this negatively? Would this change our SERPS organically and what about how Google indexes pages on the subdomain? Im also concerned that the load times will be off and make the user experience awkward. Any feedback is greatly appreciated!
White Hat / Black Hat SEO | | ChopperCharlie0 -
Submitting url to link directories seen as un-natural link building?
Hi I have been a lurker for a long time, so I finally took the step to make my 1st post, and will hopefully start giving back more in the future since I have gained invaluable info from this great site Background I hired a new freelancer on our team of SEO consultants ("specialists") During the course a month he (the new consultant) submitted our website to numerous link directories (he assured me this is good), today I received the report of the work he had been doing for the past 4-weeks. I opened the report and I was furious and wanted to sack him there and then The Problem / My Question He had submitted our website to 150 directories with various levels of page rank, ranging from 7-1. Most of the directories are totally irrelevant to our niche (we are in the catering business) and he had gone and submitted the site to directories such as "finance busters", "questfinder" etc For all 150 submissions he used: exactly the same url exactly the same title exactly the same description exactly the same keywords My Concern Am I right to be worried about this? Or am I completely wrong and may this actually have an effect (even if none)? The way I see it is that Google is seeing 150 duplicate links coming from irrelevant directories all within a months time, which will trigger a red flag and possibly do major damage to my site, which has always been strictly white hat and been doing pretty well. p.s does link directory submissions even count these days anyway? Thanks for reading and advice very much welcome
White Hat / Black Hat SEO | | timthetanker0 -
Why would my domain authority drop 2 points ?and how can i bring my domain authority back up?'.
why would my domain authority drop 2 points ?and how can i bring my domain authority back up?'.
White Hat / Black Hat SEO | | aronwp0 -
Redirecting old domains for SEO ranking?
It's been a while since I read anything seriously out of the box on SEO but I thought I would see what others thought of the bold assertions made in this article. Most of it revolves around buying expired domains and using a 301 to point them, and their juice, to new sites. This guy makes a living doing this so he has to know a bit more than the average Joe but I'm wondering where the other shoe is and when it drops.
White Hat / Black Hat SEO | | Highland0 -
Should i buy this domain because it has a keyword that im trying to rank for?
Im trying to rank for a keyword and i saw that this domain is available the top listing under this search team is a domain authority 14 and according to seo site explorer has 1 page linking to it and its a no follow link. Would it make since to buy this domain optimize it and forward it back to my main site or is this bad to do.
White Hat / Black Hat SEO | | gslc0 -
Ethical question about setting up a local business directory...
I've just launched a local business directory that allows the small businesses in my local area to get noticed by a very targeted audience. People such as self-employed builders, painters and decorators and the like. As well as helping them out, they'll be helping me out by testing the waters of local keywords and seeing just how difficult and how much traffic they'll get. Kind of like spreading myself across 100's of keywords without the need for domains etc. All the links on there are nofollow, but what are the ethics behind letting my clients have a dofollow link from it? I wouldn't use this directory as a marketing tool for my self and my business, but if I acquired a client from my website or other source, but they would benefit from a dofollow link?
White Hat / Black Hat SEO | | jasonwdexter0 -
Can you block backlinks from another domain
Wondering if this is somehow possible. A site got hacked and created a /data folder with hundreds of .php files that are web pages selling all sorts of stuff. We deleted the /data folder and blocked Google from indexing it. Just noticed in Webmaster Tools that the site has 35,000 backlinks from other sites that got hacked with the same way. Is there a way to block these sites? I am assuming there isn't, but wanted to see if anyone ran into the same problem. It is a wordpress site is that helps.
White Hat / Black Hat SEO | | phatride0 -
A domain is ranking for a plural key word in SERPs on page 1 but for the singular not at all?
What could the reasons that a domain is ranking for the plural version of a key word on SERPs page 1 and for the singular version not at all? Google knows that both key words belong together, as in the SERPs for one version also the other version of the key word is being highlighted. If I search for the domain with the plural keyword it shows up on the first page in SERPs, but If I search for the same keyword as singular (in German it is just removing an “s”) I see the plural version highlighted many times but I cannot find my domain. What could be the reason for this behavior? penalties?
White Hat / Black Hat SEO | | SimCaffe0