non www to www?

Dr.Sell

Newbie
Joined
Nov 2, 2007
Messages
29
Reaction score
24
Hi, i have a problem to add 301 redirect from non www to www please can someone please help me on what for your information this my htaccess file.


Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Thanks,
 
This works for my sites, stole it off the internet from somewhere.

Code:
RewriteEngine on 
Options +FollowSymLinks

RewriteCond %{HTTP_HOST} ^yourwebsite.com [NC] 
RewriteRule ^(.*)$ http://www.yourwebsite.com/$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.yourwebsite.com/$1 [R=301,L]
 
hi thank you,i add it after this
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
 
hi thank you,i add it after this
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I don't know enough about .htaccess files or what's written in them. But the code i wrote above is the only text i have in the entire file. I don't know what the code you have even does, if anything. Hopefully an expert can chime in here.
 
I prefer using webmasters tool to say google what is my prefered url
 
hi thank you,i add it after this
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
I would put the code chocomonkey gave you at the top of your htaccess file and then the wordpress code after.
 
Recently I redirected my site and it works well. Try this command in .htaccess file:Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^yoursite.com [nc]
rewriterule ^(.*)$ http://www.yoursite.com/$1 [r=301,nc]
 
Recently I redirected my site and it works well. Try this command in htaccess file:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^yoursite.com [nc]
rewriterule ^(.*)$ http://www.yoursite.com/$1 [r=301,nc]
 
Back
Top