HOW TO: rewrite non www to www on all addon domains and excluding sub-domains: I just spent several hours working this out, having failed to find it on the web anywhere. I figured I'd post it here. If anyone knows of any problem with using this please point it out. RewriteCond %{HTTP_HOST} !^www\..* RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} ^([^.]*)\.(com|co\.uk) RewriteRule ^.*$ http://www.%1.%2%{REQUEST_URI} [R=permanent,L] Code (markup): This will rewrite all addon domains on a hosting account to www.domain.com versions if it's in the root folder. (and your hosting is setup similar to mine). e.g. domain.com => www.domain.com domain.co.uk => www.domain.co.uk domain2.com => www.domain2.com etc. If you want more TLDs then add them in the brackets, e.g. (com|co\.uk|ca|co\.cz) It also doesn't rewrite subdomains to www e.g. forums.domain.com => forums.domain.com Hope this helps someone. J.
Sweet...that might be exactly what I'm looking for. Will try it out once I get the rest of my mod rewrite code working.
Days? I've been working YEARS.... Fantastic post. I do need a little tweaking though. I just need my base url to re-direct to a full www url. In other words, if someone surfs to "http://somnia.com", I need a redirect to "http://www.somnia.com", and that's it! hajamie, please help? Or anyone really....
The code Hajamie wrote does that. But as a bonus if someone types http://somnia.com/folder/file.html it will redirect to http://www.somnia.com/folder/file.html So it should work for you too.
I love you all in a very intense, heterosexual, you-fixed-my-problems way. But it doesn't seem to be working. I'm testing on my local machine, Windows XP Pro. I've added the following domains to my hosts file: 127.0.0.1 jokers.com 127.0.0.1 www.jokers.com Code (markup): Then the directive given above, in several places. I have also made sure to include the following: LoadModule rewrite_module modules/mod_rewrite.so Code (markup): Must my server name be defined as "www.jokers.com"? (I even tried that, and it still didn't work.)
looks to be just frontpage stuff # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName www.*********.com AuthUserFile /home/sites/*********/public_html/_vti_pvt/service.pwd AuthGroupFile /home/sites/*********/public_html/_vti_pvt/service.grp
Sweet That gets me a lot, I spent ages a while ago changing things in my htaccess to get something working, only to discover I just had to hit refresh. D'oh