Welcome Guest, Not a member yet? Register   Sign In
domain.com versus www.domain.com
#1

[eluser]jcavard[/eluser]
Hello,

I would like to know if there is anyway I can force the user to land on "www.domain.com" instead of "domain.com". Let's say the user type in the address bar "domain.com", is there any way (htaccess or rewrite rule or whatever) I can force it to land on "www.domain.com".

This is because the ci_session cookie gets created on www.domain.com AND domain.com, I would like to avoid having 2 differents cookies for the same site. Anyone has come up with that issue before?

many thanks in advance,
#2

[eluser]TheFuzzy0ne[/eluser]
You'd need something like this in your htaccess file:

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

[eluser]jdfwarrior[/eluser]
Could also just do something like, check the $_SERVER['HTTP_HOST'] variable. If its domain.com, do a redirect to www.domain.com
#4

[eluser]TheFuzzy0ne[/eluser]
Also, you can share cookies over your domain name, but setting your domain name like so:
Code:
$config['cookie_domain'] = '.example.com'; # I think this is the right syntax, but don't quote me.
#5

[eluser]jdfwarrior[/eluser]
[quote author="TheFuzzy0ne" date="1245190859"]Also, you can share cookies over your domain name, but setting your domain name like so:
Code:
$config['cookie_domain'] = '.example.com'; # I think this is the right syntax, but don't quote me.
[/quote]

Cookies should always be shared. Especially chocolate chip cookies.
#6

[eluser]TheFuzzy0ne[/eluser]
[quote author="jdfwarrior" date="1245191060"]Cookies should always be shared. Especially chocolate chip cookies.[/quote]

Sure, chocolate chip cookies, but not double chocolate chip or those really cool ones with the M&Ms in them...
#7

[eluser]jcavard[/eluser]
thank you guys for the quick answer.

I agree on the chocolate chip cookies, they're mine.




Theme © iAndrew 2016 - Forum software by © MyBB