301 Redirect being a bitch

RockDiesel

New member
Nov 29, 2007
1,419
16
0
I have been trying to set up a 301 redirect and it is being a pain in my ass. I have been using the following code in the .htaccess file but to no avail.

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

I have also logged in to DirectAdmin and inputted the 301 redirect in the control panel there, but still not working.

Every time I visit mysite.com I just get the message "Apache is functioning normally", instead of it redirecting to www. mysite.com

I am sure there is some little thing I am missing, but I can't figure it out. Is it a server problem and not a code problem? I have never had any trouble like this with 301 redirects before.
 


Check your apache error log for that website, it may tell you whats wrong. Maybe you need Options +FollowSymLinks in the .htaccess too.

But I normally use this code for www redirecting:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ htp://www.domain.com/$1 [L,R=301]