How to specify www vs. non-www - with Pretty URLS - on new install?

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
WebGirl

How to specify www vs. non-www - with Pretty URLS - on new install?

Post by WebGirl »

Not sure if this is the right location for this question.

Installation: CMSMS 1.5.4
PHP: Ver 5

My client wants to only see 'www' in her site's URL, which is normally achieved by amending the htaccess file

I've been advised to add this to the .htaccess:

--
RewriteEngine on
RewriteCond %{HTTP_HOST} ^website-name.com [NC]
RewriteRule ^(.*)$ http://www.website-name.com/$1 [L,R=301]

--
Of course I replaced 'website-name.com' - with the real live website name :)

I had already set up Pretty URLs, so once I added this, the Pretty URLs stopped working, and I could no longer login to the Admin.

Does anyone know of the best way to implement (1) Pretty URLS, with (2) 'www' - either using .htaccess or some other way?

I really have no knowledge of how to write the .htaccess apart from using it for Pretty URLs.

Any assistance is greatly appreciated!

Many thanks
Last edited by WebGirl on Wed May 13, 2009 5:56 am, edited 1 time in total.
Jean le Chauve

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by Jean le Chauve »

Hi,

Code: Select all

RewriteCond %{HTTP_HOST} ^domaine.com$ [NC]
RewriteRule ^(.*)$ http://www.domaine.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^.*domaine.com [NC]
RewriteRule (.*) http://www.domaine.com/$1 [R=301,L]
config.php :
$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '.html';
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;  //optional
$config['root_url'] = 'http://www.domaine.com';
WebGirl

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by WebGirl »

Merci Jean!

OK just so I've got this right - this goes in .htaccess:
RewriteCond %{HTTP_HOST} ^domaine.com$ [NC]
RewriteRule ^(.*)$ http://www.domaine.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^.*domaine.com [NC]
RewriteRule (.*) http://www.domaine.com/$1 [R=301,L]
and this goes in config.php :
$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '.html';
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;  //optional
$config['root_url'] = 'http://www.domaine.com';
Fantastique! I'll give that a shot!

Thanks a million!
viebig

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by viebig »

or you can just change

Code: Select all

$config['root_url'] = 'http://www.domaine.com';
to

Code: Select all

$config['root_url'] = 'http://domaine.com';
no htaccess changes

Regards
Jean le Chauve

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by Jean le Chauve »

Jean le Chauve wrote: Hi,

Code: Select all

RewriteCond %{HTTP_HOST} !^.*domaine.com [NC]
RewriteRule (.*) http://www.domaine.com/$1 [R=301,L]
Edit : this 2 lines make a second redirection => bad
WebGirl

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by WebGirl »

Thank you everyone for trying to help.

I cannot solve this.

I have spent days tweaking the htaccess and config.php files, I've checked the templates, and still this issue cannot be resolved. I have paid someone else to investigate it (a cmsms person).

This client website had the 'www' working AND Pretty URLS in version 1.1, but now we've upgraded to 1.5.4 nothing can put this back the way it was.

The client's request is simply that if someone types their domain name without the 'www', that it should always resolve to the 'www' version. This is for Google search engine, webmaster and analytics - so there is no 'duplicate content' on a non-www version of the site.

Unfortunately I have had to tell the client that she cannot have both www and pretty urls in CMSMS 1.5.4.

:(
nuno

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by nuno »

Like viebig  said  put this in your config.php

$config['root_url'] = 'http://www.domaine.com';

http://www.domaine.com  is your domain ofcourse ;)

Done
WebGirl

Re: How to specify www vs. non-www - with Pretty URLS - on new install?

Post by WebGirl »

Hi Nuno,

Yes I have done that.

Thanks :)
Locked

Return to “[locked] Installation, Setup and Upgrade”