Page 1 of 1

permanent 301 redirect on domain - am I doing it right?

Posted: Sat Mar 20, 2010 6:04 pm
by darksaga
Hey guys,

I've been looking for some information in regards to a permanent 301 redirect from a http://yourwebsite.com/ to http://www.yourwebsite.com/.

Most of the topics deal with re-directs of pages within certain domains or pages from one domain to another. I don't know much about PHP, but I do know this:

1) I need an .htaccess file in the root of my site.
2) The script should look something like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourwebsite.com.
RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [R=permanent,L]

Is this correct? It doesn't seem to be working. Every time I check in Google's websmaster tools, it doesn't show the 301 redirect. Am I doing this right? Or what am I missing in the .htacess file?

Any help is appreciated,

K

Re: permanent 301 redirect on domain - am I doing it right?

Posted: Tue Mar 23, 2010 3:30 pm
by Loopy
This is a canonical issue and as far as I know if you have this piece of code after your tag it should redirect automatically

eg:


GetURL()}{/if}" />

Hope this helps.

Re: permanent 301 redirect on domain - am I doing it right?

Posted: Tue Apr 27, 2010 9:42 am
by stijlXpres
For a 100% working 301 redirect I insert these 2 lines in the .htaccess:

Code: Select all

RewriteCond %{HTTP_HOST} ^www\.yourwebsite\.com [NC]
RewriteRule ^(.*)$ http://yourwebsite.com/$1 [L,R=301]
Notes:
1. As you see this redirect is the other way-around, for it removes the 'www.' In my opinion we don't need the oldfashioned prefix (but watch out, some servers still do...)
2. I always use the htaccess.txt from CMSMS I find in the DOC-folder in the root of the install

I don't know exactly what Google's webmaster tools say about this, but it works like a charm!

Good luck!