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
permanent 301 redirect on domain - am I doing it right?
Re: permanent 301 redirect on domain - am I doing it right?
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.
eg:
GetURL()}{/if}" />
Hope this helps.
- stijlXpres
- 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?
For a 100% working 301 redirect I insert these 2 lines in the .htaccess:
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!
Code: Select all
RewriteCond %{HTTP_HOST} ^www\.yourwebsite\.com [NC]
RewriteRule ^(.*)$ http://yourwebsite.com/$1 [L,R=301]
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!