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

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
darksaga
Forum Members
Forum Members
Posts: 10
Joined: Sat Nov 07, 2009 8:42 pm

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

Post 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
Loopy
Forum Members
Forum Members
Posts: 38
Joined: Sat Jun 10, 2006 5:34 pm

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

Post 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.
User avatar
stijlXpres
Forum Members
Forum Members
Posts: 137
Joined: Tue May 05, 2009 12:10 pm
Location: Raalte, the Netherlands

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

Post 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!
Post Reply

Return to “The Lounge”