Welcome Guest, Not a member yet? Register   Sign In
Session issue with and without www
#1

[eluser]Arun Joshi[/eluser]
Hi,

Am facing a serious issue when the site went live. I have set base url as http://mysite.com. In this case everything working fine. But if we try http://www.mysite.com the session is not working. I think CI is using cookies store session values. So it may consider these as two different domains. Is this the issue? Is there any method to solve this situation.

Thanks
Arun
#2

[eluser]Twisted1919[/eluser]
www. is treated as a subdomain of domain.com, so yes there are 2 distinct cookies .
In the config.php find the cookies section and fill it with the needed info, this will make your problem go away.
#3

[eluser]Arun Joshi[/eluser]
@Twisted1919,

Can u describe it more? which field to edit? is it $config['cookie_domain']?

If yes, what should be needed there? http://www.mysite.com or http://mysite.com ?

Please reply. Thanks in advance...
#4

[eluser]InsiteFX[/eluser]
The following code is straight forward:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

.htaccess file at your domain root and it will work for the entire domain (including subfolders).

NOTE: You may need to change the /$1 to ?$1

InsiteFX
#5

[eluser]Arun Joshi[/eluser]
Hi,

My current htaccess file is
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|uploads|ckeditor|photos|albums|books|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Then how to modify this?

-Arun
#6

[eluser]InsiteFX[/eluser]
Did you try removing the /$1 and using a ?$1 instead?

InsiteFX
#7

[eluser]Arun Joshi[/eluser]
@InsiteFX,

I want to redirect http://www.yourdomain.com to http://yourdomain.com.

So I think the rewrite rule is

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

Then how to include my previous condition
Code:
RewriteCond $1 !^(index\.php|images|css|js|uploads|ckeditor|photos|albums|books|robots\.txt)

Actually am not familier with htaccess rules. Can u give me an htaccess which has the above rules?

-Arun
#8

[eluser]Arun Joshi[/eluser]
Can we add multiple rewrite conditions in a htaccess file?
#9

[eluser]InsiteFX[/eluser]
Yes you can

InsiteFX
#10

[eluser]Arun Joshi[/eluser]
How to combine

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

and
Code:
RewriteCond $1 !^(index\.php|images|css|js|uploads|ckeditor|photos|albums|books|robots\.txt)
in a signle htaccess file?




Theme © iAndrew 2016 - Forum software by © MyBB