301 Redirect Just Not Working :-(

Good Morning from 14 degrees C Wetherby UK :slight_smile:

On this site [noparse]www.davidclick.com[/noparse] I ran a canonical error test (screaming frog) to learn I had indeed to versions of my Home page i.e.
[noparse]www.davidclick.com[/noparse] & [noparse]www.davidclick.com/index.htm[/noparse]

Having learnt this i then jumped into my ht acccess file & added this line of code:
301 /index.htm http:[noparse]www.davidclick.com[/noparse]
But that didnt work in that an error warning -
“Firefox has detected that the server is redirecting the request for this address in a way that will never complete.”

So my question is please… “How do i fix the canonical error two versio0ns of my home page is generating”

Footnote: I have noticed also each there is a <link rel=“canonical” href=“http://www.davidclick.com”/> on the home page & wonder if this could be cocking things up.

Any insights welcome :slight_smile:

Take a look again at your command.
301 /index.htm http:[noparse]www.davidclick.com[/noparse]

First, I believe it should have the word Redirect in front of the 301, second, you are missing the slashes after the http:
Redirect 301 /index.htm [noparse]http://www.davidclick.com[/noparse]

[font=verdana]As cpradio says, you’re missing a // from your 301 line, but assuming that’s just bad copying … I’m not entirely sure what the problem is. Your canonical link is exactly what I would expect to see, telling search engines that whatever route they have arrived at the page by you want them to index it as [noparse]www.davidclick.com[/noparse]. I wouldn’t worry about any other redirects.

The problem with trying to use a redirect to get rid of the ‘index.htm’ is that you end up in an infinite loop. When you ask for [noparse]www.davidclick.com (or any other URL that doesn’t end with a filename), the server needs to give a page and so automatically appends ‘index.htm’ (or whatever you have selected as your default filename) onto the end, and asks for www.davidclick.com/index.htm. The server then thinks “Hmmm, I have to redirect that URL to www.davidclick.com” and then it all goes round again.[/noparse][/font]

Big thank you for you replies, Ive knocked off the the ht access redirect bit :slight_smile:

Aw, if the www and non-www’d domains are co-located (as they usually are), then the correct code above (cprado) will generate an endless loop. That’s where the power of mod_rewrite comes in: Check whether www or non-www and redirect the non-www to the www’d URL, i.e.,

RewriteEngine on
RewriteCond %{HTTP_HOST} ^davidclick\\.com$ [NC]
RewriteRule .? http://www.davidclick.com%{REQUEST_URI} [R=301,L]

All this is in the tutorial linked in my signature so I’d recommend reading to know why this is the code (see Sample Code - force www) to use.

Regards,

DK