1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Force non-www redirection to www in subdomain installation

Discussion in 'XenForo Questions and Support' started by mcmedal001, Jul 6, 2014.

  1. mcmedal001

    mcmedal001 New Member

    Hello,

    I have xenforo installed on a subdomain on my website (www.ngscholars.com/comm/). I just discovered that the www version and non-www version of the site are opening separately.

    From SEO point of view, I may not have ay issues because I have claimed both www and non-www version in Google Webmaster tools and set my preferred domain as the www version.

    The issue I currently have now is this:

    If a user logs in to the community with the www appended to the URL and later clicks on a link on the site without www, they get logged out. I have searched this forum and tried out every recommendations (editing .htaccess) made by Jake and others to no avail.

    I'm here to seek help from members and support staff who have done this before.

    NB: My forum is installed in a subdomain at www.ngscholars.com/comm

    Thank you
     
  2. Martok

    Martok Well-Known Member

    http://xenforo.com/community/threads/frequently-asked-questions.5183/

    If you have read and followed these instructions and its still not working, you'll have to post more details about your server setup (is it Apache?), exactly what you did (including your .htaccess edits) and any other relevant details if others are to help you with this.
     
  3. mcmedal001

    mcmedal001 New Member

    I have tried all the suggestions in this post you gave me but none worked. My server is nginx and the only modification I made is adding the code xenforo gave to enable SEF URLs. What else can I do?
     
  4. Martok

    Martok Well-Known Member

    Post the contents of your .htaccess file so others can see what you have done.
     
  5. mcmedal001

    mcmedal001 New Member

    This is what I have in my .htaccess file without the codes for redirection.

    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
       #   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>
    Thank you!!!
     
  6. Martok

    Martok Well-Known Member

  7. mcmedal001

    mcmedal001 New Member

    Thank you for that link. I did what's on that page as explained but it's still not redirecting. What else can be done please?

    In Basic board configuration, I have:

    Board URL: http://www.ngscholars.com/comm
    Index page route: forums/
    Home page URL: http://www.ngscholars.com
     
  8. Martok

    Martok Well-Known Member

    You already have a rewrite in place, as ngscholars.com goes to www.ngscholars.com. You need to look at what you have done for that to make sure it works for all instances. So that will be editing a .htaccess file in your root.
     
  9. mcmedal001

    mcmedal001 New Member

    That is another application (WP) and it was configured in the Wordpress .htaccess. Is this going to work for xenforo i the subdomain?
     
  10. Martok

    Martok Well-Known Member

    I believe you'll have to sort out the non-www to www redirects in the .htaccess file in the root.
     
  11. mcmedal001

    mcmedal001 New Member

    Thank you for your help so far. I don't have any idea of what to do next. If it should be done in the root, the it should be working as it is working for the root directory.
     
  12. Martok

    Martok Well-Known Member

    What's your .htaccess code in the root?
     
  13. mcmedal001

    mcmedal001 New Member

    Here is what I have in the .htaccess of the WP installation:
    Code:
    # -FrontPage-
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName ngscholars.com
    AuthUserFile /home/ngschola/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/ngschola/public_html/_vti_pvt/service.grp
    
    # 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>
    
    # END WordPress
    
    Thank you
     
  14. Martok

    Martok Well-Known Member

    There's no re-write in there for non-www to www.

    Is the non-www to www being done in your Web hosting control panel? Is so, you'd be better switching it off there and adding it to the .htaccess file using this:

    Code:
        # Redirect non-www to www
        RewriteCond %{HTTP_HOST} ^website\.com [NC]
        RewriteRule (.*) http://www.website.com/$1 [NC,QSA,L,R=301]
    using your website URL, of course.
     
  15. mcmedal001

    mcmedal001 New Member

    Thank you, I will work on that. Finally, do I need to still add the redirect code for xenforo after doing it in the WP too? Thank you
     
  16. Martok

    Martok Well-Known Member

    The redirect you require is in my previous post.
     
  17. Tracy Perry

    Tracy Perry Well-Known Member

    Is your server (actual HTTP server) nginx, or are you using it as a proxy.

    .htaccess doesn't come into play with nginx. The rewrites are typically done in the vhost itself or in a file that is included.
     
  18. mcmedal001

    mcmedal001 New Member

    Thank you for this response. I'm not really sure if it is the actual http server or a proxy. I will contact my server manager for that. If it is the real server, what do I ask him to do for me? Thanks
     
  19. Tracy Perry

    Tracy Perry Well-Known Member

    Main thing is whether you are running it as a proxy or not. If running it as a simple proxy for Apache, then the htaccess rewrites should work. If not using it as a proxy (but as primary content server) then the rewrites will need to be done in the vhost definition.

    I use IPv6 on my sites... so this would need to be changed to reflect non-IPv6.
    What this does is take all inbound requests to the www portion of the site (it has two domains pointing at it) and routes them with a 301 redirect to the non-www site.

    Code:
    server {
    # ipv4
    listen 80;
    # ipv6
    listen [::]:80;
    
        server_name www.nowservinglinux.com nowservinglinux.com www.nowservinglinux.com;
        return 301 https://servinglinux.com$request_uri;
    }
     
  20. mcmedal001

    mcmedal001 New Member

    I understand clearly now. I will inform my server manager and get back to you here. To be double sure, which redirection code should I give to him, considering that I have it installed in a sub-domain. Thank you
     

Share This Page