Www/no-www problems

I’m trying to redirect http://www.site.com to http://site.com but it seems there r some problems like sometimes i wont be able to log in and now my favicon wont appear… It appears fine for http://www.site.com but http://site.com has no favicon… does any1 know why?

I’m using this in the .htaccess file


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

Here’s what I use:

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

enwise & F00,

You’re trying to capture multiple domains with this? Okay, that’s reasonable as domains can be parked in the same physical space.

Why not escape your dot characters in the regex, though and merely use {REQUEST_URI} rather than waste the time to capture it again as $1?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\\.(.+) [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

Of course, you would have seen this in my signature’s tutorial if you’d just looked. There are MANY more coding examples, too, so give it a try. You (and F00) may learn why NOT to use lazy regex (the (.*)), too!

Regards,

DK

I really have no idea about anything that goes into the htaccess file… so i dont know what $1 does… I was told some solutions work and some dont it just depends on my server setup… im going to be moving my servers tonite to another webhost and then im going to get back to this post and see how things go :slight_smile: thanks for the help so far!