I have a .htaccess file which forwards non www request to www

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

However, I have a problem if i were to put into the url mysite.com/test.php it will not forward to the www site. Any help on how i can get this fixed would be greatly appreciated. It does work if I just put mysite.com it will forward it to http://www.mysite.com. It just doesn't work when i add mysite.com/test.php

Thanks.

Is it a linux server with apache mod-rewrite module installed? Why not use a simple html redirect

<meta http-equiv="refresh" content="2;url=http://www.yoursite.com">

this wouldnt work because I have multiple websites hosted on this linux server. That would redirect all of the websites that resolve to my ipaddress

i have tried this..
its worked fine for me...

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

i have tried this..
its worked fine for me...

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

That worked perfectly thank you.

hey,,,
have u tried rewrite conditions in your .htaccess file..
the explain me...please...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.