PDA

View Full Version : strange .htaccess redirect problem



kathyb
04-24-2007, 12:31 AM
I have put a .htaccess file in my var/www/ directory in an attempt to redirect traffic from domain.com to www.domain.com

this is how it looks:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

it is redirecting to

www.domain.com/domain/

any idea why this is happening?
Thanks.

wildjokerdesign
04-24-2007, 06:49 AM
Try placeing it in /var/www/html instead.

kathyb
04-24-2007, 10:32 AM
Thank you for your response.

I tried that, now it doesn't redirect at all.

I also tried to redirect using an index.php file. It worked to redirect www.domain to www.domain/shop , but doesn't work in this case (same domain) What else can I try?

wildjokerdesign
04-24-2007, 07:27 PM
Try this in /var/www/html/

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