XF 1.5 Xenforo won't work on non-www URLs

TomCann

Member
I have a XenForo installation in a /community/ subfolder. The rest of the website auto-redirects to non-www. However Xenforo won't operate on a non-www URL, upon accessing /community, the forum just doesn't appear and reverts to the parent website's wordpress 404 page.

The only solution has been a htaccess file in the /community folder which autoredirects to the www. version of the URL, and then the forum runs properly, using the following:

RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC]
RewriteRule ^(.*)$ https://www.wine-pages.com/community/$1 [R=301,L]

Ultimately I want everything on non-www. Thanks in advance for any help.
 
1. What happens if you change

Code:
RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC]
RewriteRule ^(.*)$ https://www.wine-pages.com/community/$1 [R=301,L]

to

Code:
RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC]
RewriteRule ^(.*)$ https://wine-pages.com/community/$1 [R=301,L]


2. What do you have in the setting for AdminCP >> Settings >> Options >> Basic Board Information >> Board URL: ?

It should say https://wine-pages.com/community (no trailing slash).
 
1. What happens if you change

Code:
RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC]
RewriteRule ^(.*)$ https://www.wine-pages.com/community/$1 [R=301,L]

to

Code:
RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC]
RewriteRule ^(.*)$ https://wine-pages.com/community/$1 [R=301,L]


2. What do you have in the setting for AdminCP >> Settings >> Options >> Basic Board Information >> Board URL: ?

It should say https://wine-pages.com/community (no trailing slash).

Changing the htaccess like that gets it into a redirect loop. Edge shows the error as this: "Error Code: INET_E_REDIRECT_FAILED"

The board URL is/was correct

Thank you for your help so far
 
Maybe try this one..
Code:
RewriteCond %{REQUEST_URI} (.*)
RewriteRule ^(.*)$ https://wine-pages.com/community/$1 [L,R=301]
Or..
Code:
RewriteCond %{HTTP_HOST} ^wine-pages/community\.com$ [NC]
RewriteRule ^(.*)$ https://wine-pages.com/community/$1 [R=301,L]

Whats about to activate RewriteBase /community
 
Thought I'd just quote the whole htaccess file just for clarity
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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On
    
   RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC]
        RewriteRule ^(.*)$ https://www.wine-pages.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 /community

    #    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]
    RewriteCond %{HTTPS}s ^on(s)|


</IfModule>

RewriteBase /community is already on

I'll try those two now
 
No dice on those two. First one gives the redirect loop again, the second one yeilds the same result as moving the rewrite snippet entirely, which is this, like a styleless snippet of the site menu and that's it.

 
Try this on..
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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
   RewriteEngine On
      
   RewriteCond %{REQUEST_URI} (.*)
   RewriteRule ^(.*)$ https://wine-pages.com/community/$1 [L,R=301]

    #    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 /community

    #    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]
    RewriteCond %{HTTPS}s ^on(s)|
</IfModule>

If you use RewriteCond %{HTTP_HOST} ^wine-pages\.com$ [NC] you will get an loop every time, cause of your htaccess in the root.
 
@mcatze that yeilds another redirect loop unfortunately.

Thought I'd show the redirect portion of the root htaccess, just in case it helps:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
Ouch, you can't open an IF-Tag without closing it.
Try this one in root.
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [OR]
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # RewriteBase /
   
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
 
@mcatze thanks - having a quick count there is an even number of open and closing if-tags but the ordering seems odd (I think some wordpress plugins have meddled with things a bit). Either way I've made your modification, and tested the other permutations of the /community htaccess, and it yields exactly the same results unfortunately.
 
Back
Top Bottom