Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » How do I…?
  3. » Force WWW

#1 2008-08-19 20:47:42

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Force WWW

My host allows you to access my site at either http://domain.com/ or http://www.domain.com/ as you would expect.
The problem is that the two differ in terms of cookies and I really hate it, because if i say by accident miss the / of the end of a URL then it automatically drops the WWW?

How can I force WWW. so say if someone went to http://domain.com/about/ it would automatically change this to http://www.domain.com/about/

THANKS> x


~ Cameron

Offline

#2 2008-08-19 21:05:51

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Force WWW

To top of your root .httaccess file:

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

Replace example.com with your domain.

Offline

#3 2008-08-19 21:41:07

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Force WWW

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
RewriteCond %{HTTP_HOST} ^simplecandy.com
RewriteRule (.*) http://www.simplecandy.com/$1 [R=301,L]

This is my code, how do I make it so it all works together :S
At the moment its now going http://www.simplecandy.com/index.php/

Last edited by driz (2008-08-19 21:44:26)


~ Cameron

Offline

#4 2008-08-19 21:45:50

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Force WWW

Gocom wrote:

To top of your root .httaccess file:

To the top! :)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2008-08-19 21:49:55

driz
Member
From: Huddersfield, UK
Registered: 2008-03-18
Posts: 441
Website

Re: Force WWW

Ah right it’s working now :)
Quick Q though, what does this do?

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php

~ Cameron

Offline

  1. Index
  2. » How do I…?
  3. » Force WWW

Board footer

Powered by FluxBB