301 redirect (www.domain.com/index to www.domain.com)
-
Hello,
Please let me know what are the exact right steps in order to get rid of the duplicate content issues related with:
www.domain.com/index.html same as www.domain.com without creating an infinite loop.
Do you have a step by step guide posted within seomoz including 301 redirect for non www to www for all urls and index.whatever to main domain name without going into a infinite loop ?
btw how to you spot the loop ? is it obvious like never ending refresh of the home page ?
thanks a lot !
-
Well, I would recommend you alter the internal links to just point to the new '/' default, but in the meantime...
I would have thought your code would have worked, but every time I try it my site falls over. It might work for you though. Give it a try but test it straight away
I'll see if I can get a different version working on my test site for you if not
-
seomoz tool is showing duplicate pages for those 3. Each of the version has at least 1 internal and even external links.
all 3 respond in the browser with the same layout/page
-
Hmm, maybe, I doubt the index.php is doing anything as if there's a index.html and index.php the .html takes precedence.
Check what's in the .php file, might be easier just to delete it.
-
Can I use a code like this ? (i've added one entry for index.php as it looks like the site has both an index.html and an index.php)
Barry Smith
Journeyman264 mozpoints
6 helpful answers
1 SEOmoz endorsed answers| Helpful Answer | Barry Smith, Head of SEO at Gaming Media Marketing | about 2 hours ago |
Probably the simplest way to redirect the non-www to the www is to put this in your .htaccess file
RewriteEngine On Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.)index.html$ http://www.example.com/$1 [R=301,L]RewriteCond %{THE_REQUEST} ^./index.php
RewriteRule ^(.)index.php$ http://www.example.com/$1 [R=301,L] -
Thanks mate !
More then helpful.
-
Yeah, if it doesn't work you'll probably be faced with a blank page or you may get a 500 server error or maybe a 310. It should be obvious pretty fast
-
how it will behave if the redirect is not correct ? It will be visible ? (like a never-ending refresh of the main page)
-
I agree with Barry, but watch out for that last snippet. I've got caught when hosting companies redirect on their side. So test before walking away for more coffee : )
-
The last part redirects index.html to /
There would only be a loop if you redirected / to index.html
99.9% sure this'll work for you I'm using the exact code on a small site right now and it's working fine
-
is the last part safe ? as far as the infinite loop things that some are afraid of..
-
Probably the simplest way to redirect the non-www to the www is to put this in your .htaccess file
RewriteEngine On Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.)index.html$ http://www.example.com/$1 [R=301,L]For reference the .htaccess file goes in the root of your domain via whatever file transfer program you use and of course replace example.com with your domain
If you get stuck, let me know
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
-
No difference anymore between 301 and 302
According to http://searchengineland.com/google-no-pagerank-dilution-using-301-302-30x-redirects-anymore-254608 What do you think?
On-Page Optimization | | nans0 -
How should we act regarding a 404 that came from a 301?
Hi! Some time ago we changed our domain from canexel.net to canexel.es. We spent some time "cleaning" the backlinks to the ".net" domain since we had been penalized by penguin. After some time we went ahead and did a 301 from .net to .es january 15. From that date on we've noticed that webmaster tools has been detecting a really big increase oon 404 detected on our site. All this 404 come from .net pages that have been cached by google but don't exist anymore. The problem is that the 301 has made google believe that they exist also on our .es site (where of course don't exist either), and 404 have appeared from this non existing pages pinting to other non existing pages. We want to to eliminate the urls from WMT but we don't know if we should eliminate them both from the .net and .es domains or just from the .net one. We also would like to know if this would penalize our SEO. Thanks
On-Page Optimization | | Canexel0 -
Google Indexed = 35, 445 pages, Bing Indexed = 243 pages... Why?
Dear MozSquad, Can anyone check our site and let me know if there's anything super apparent that would cause Bing to treat us like a bum on the street? I recently made some structural changes which really helped with Google, but Bing didn't even budge. It's a lot harder to keep up with all the SEO initiatives I have in mind with it being a small start-up where I'm responsible for planning the entire Internet Marketing campaign, giving constant input on UX and site design, etc on top of 900 other things, so I figured it'd be a good time to use The Moz to help a brother out. Ideas? Domain: homeandgardendesignideas.com (yeah, I know it's a little long =P)
On-Page Optimization | | zDucketz0 -
Rebranding and Domain Name Changes
Hi All, One of my clients wants to rebrand http://indiaretailnews.com/ so that it's clear that the site is under the operational umbrella of http://tradebriefs.com/. indiaretailnews.com has a lower domain authority of 20, but because of the domain name it ranks number #2 for the keyword "retail news" for Google India. The client's question: Can we change the site names to TradeBriefsRetail.com orTradeBriefsIndiaRetail.com without affecting the SEO on each site? How do we do this – redirect from TradeBriefsIndiaRetail.com to IndiaRetailNews.com and so on or simply put all the content on the new sites and get rid of the old domains or some other way? Do long domain names cause a problem? Another option is TradeBriefsRetail.in, etc with the domain extension showing the country that the content is for.. In a year or two, we will be expanding to markets outside India. My opinion: Keep the old domains and redirect to something like http://tradebriefs.com/india-retail-news Or perhaps a subdomain: http://indiaretailnews.tradebriefs.com In the short term, I'd imagine rankings will drop, but if we wanted to consolidate domain authority, I was thinking that http://tradebriefs.com/india-retail-news would be the best bet. Thoughts? Kenji
On-Page Optimization | | KenjiCrosland0 -
How do I switch my website to www.mydomain?
I'm having canonical URL problems. I keep trying to set everything to www.mydomain.com, but I'm using wordpress and my site keeps either disappearing completely or giving me an infinite loop error. I've tried changing my main wordpress setting, whether I have canonical URLs turned on, my .htaccess file... Could this be an issue with either my host or my domain registrar? Any ideas how I can fix it?
On-Page Optimization | | lauragee0 -
404 crawl errors with all url+domain
We have 187 crawl 404 errors. All urls on web make a 404 error that this http://www.domain.com/[.....]l/www.domain.com all errors added to the url, the url domain I put an example gestoriabarcelona.com/www.gestoriabarcelona.com
On-Page Optimization | | promonet
gestoriabarcelona.com/tarifas/www.gestoriabarcelona.com
gestoriabarcelona.com/category/noticias/page/7/www.gestoriabarcelona.com
gestoriabarcelona.com/2012/08/amortizacion-de-unaconstruccion/
www.gestoriabarcelona.com
[..] I don't know where can i find to solve errors Anyone can help me? Thanks0 -
Temporary Redirects
On my crawl report from SEOmoz, I have a lot of Temporary Redirects listed. The referring site is a product category page, but the URL listed is part of a shopping cart. For example: | http://www.adagiowaterfeatures.com/cart.php?action=add&product_id=496 | Tested true for a temporary redirect referred by this url: | http://www.adagiowaterfeatures.com/categories.php?category=Free-Standing-Water-Features/Harmony-River-Collection | Why does this occur and what can I do about it?
On-Page Optimization | | AdagioWaterFeatures0 -
301 redirect and then keywords in URL
Hi, Matt Cutts says that 301 redirects, including the ones on internal pages, causes the loss of a little bit of link juice. But also, I know that keywords in the URL are very important. On our site, we've got unoptimized URLs (few keywords) in the internal pages. Is it worth doing a 301 redirect in order to optimize the URLs for each main page. 301 redirects are the only way we can do it on our premade cart For example (just an example) say our main (1 of the 4) keywords for the page is "brown shoes". I'm wondering if I should redirect something like shoes.com/shoecolors.html to shoes.com/brown-shoes.html In other words, with the loss of juice would we come out ahead? In what instances would we come out ahead?
On-Page Optimization | | BobGW0