XF 1.1 www vs. non-www domain [logging isssues]

TheBigK

Well-known member
I've found out that our XF board does not handle the www and non-www logging-in properly. Let's say a user enters: domain.com and logs in; and then clicks a URL that begins with www.domain.com/threads/.... , then the new page that opens has already logged out the user.

I know that technically, www and non www domains are technically two different addresses. But is there a way this can be fixed?

Say, even if the user enters domain.com, he/she should be directed to the www version? I'd like to enforce www in my domain addresses.
 
Jake, I actually want to enforce 'www' for all forum pages. That is, I want all the pages should begin with www.crazyengineers.com/community/...

Then use this. Again, it's in the .htaccess file inside of your /community directory:

Rich (BB code):
#	Mod_security can interfere with uploading of content such as attachments. If you
#	cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#	SecFilterEngine Off
#	SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

<IfModule mod_rewrite.c>
	RewriteEngine On

	RewriteCond %{HTTP_HOST} !^www\.yoursite\.com$
	RewriteRule ^(.*)$ http://www.yoursite.com/community/$1 [R=301,L]

	#	If you are having problems with the rewrite rules, remove the "#" from the
	#	line that begins "RewriteBase" below. You will also have to change the path
	#	of the rewrite to reflect the path to your XenForo installation.
	#RewriteBase /xenforo

	#	This line may be needed to enable WebDAV editing with PHP as a CGI.
	#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -l [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^.*$ - [NC,L]
	RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
	RewriteRule ^.*$ index.php [NC,L]
</IfModule>

That will enforce "www" on all forum pages.
 
Old is gold.

Anyway; I just tried Sadik's suggestion and found out that if I type crazyengineers.com/community/ , I get redirected to www.crazyengineers.com ! Not what I want.

That happened because you put my rules in the community folder where as I told you to put it in the root folder of the domain.

Remove any www/non www url rewrite from the htaccess file of your community folder.
Add what I had given in the root folder's htaccess.
It WILL work, I use it on half a dozen sites.
 
Top Bottom