Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

Trying to use www. in domain name via .htaccess

Joined
Nov 11, 2005
Posts
2,257
Reaction score
519
Really puzzled by this.

I've added this code to my .htaccess file:

# Always use www in the domain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([a-z.]+)?domainname\.co.uk$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .? http://www.domainname.co.uk%{REQUEST_URI} [R=301,L]

But it doesn't seem to work.

Any ideas what I'm doing wrong?
 
This is what I use on the majority of mine.

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

Edit , sorry just saw you used that in your second post. Above is slightly different though.
 
Thanks Adam. I think I'll contact my host because that should work shouldn't it? Although I see my second example is slightly different to yours so I'll try it.

Edit tried yours but still no www. showing
 
Thanks Adam. I think I'll contact my host because that should work shouldn't it? Although I see my second example is slightly different to yours spo I'll try it.

Yes it should, try my example above as it is very slightly different to yours. If that doesnt work your host must have some weird config. I assume you are doing it from the root domain and not some subdirectory like /blog or /forum. Providing you are doing it from the root folder the above should work.

Also might be worth clearing your cookies and cache, many of times ive got wound up with things not working only to find they are working..........just my cache was playing up
 
Found out the problem. My .htaccess was called .htaccess.htm.... Doh

So annoying when you spend hours trying to work out why something isn't working and then notice something like that!!! :mad:
 

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

Latest Comments

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom