Membership is FREE – with unlimited access to all features, tools, and discussions. Premium accounts get benefits like banner ads and newsletter exposure. ✅ Signature links are now free for all. 🚫 No AI-generated (LLM) posts allowed. Share your own thoughts and experience — accounts may be terminated for violations.

Trying to use www. in domain name via .htaccess

Joined
Nov 11, 2005
Posts
2,259
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
 

Rule #1: Be Respectful

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

Members online

Premium Members

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.
  • Systreg AcornBot:
    Systreg has left the room.
      Systreg AcornBot: Systreg has left the room.
      Top Bottom