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

XF 1.2 Site domain not working unless site.tld/forum/

Discussion in 'Troubleshooting and Problems' started by SniperBrob, Mar 7, 2014.

  1. SniperBrob

    SniperBrob Member

    Well long story short, after the long and grueling process of transferring my site over to my new host (which actually was a lot easier than I made it out to be) I am having a problem with my site. When I go to http://hossfactions.com , it tells me there is a redirect loop, but when I go to http://hossfactions.com/forum/index.php it works fine. Why is this happening and how can I fix it?
  2. Brogan

    Brogan XenForo Moderator Staff Member

    What is in the .htaccess file in your root?
  3. SniperBrob

    SniperBrob Member


    # 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

    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]
  4. Mike

    Mike XenForo Developer Staff Member

    That's the standard XenForo htaccess. And that's at the root of your domain?

    It looks like you've installed XF into /forum, so anything that's outside of that shouldn't be involved with XF. (Presumably you are trying to redirect to /forum/index.php?)
  5. SniperBrob

    SniperBrob Member

    I don't really know what you mean by "root of your domain". The file I pasted was located at /var/www/forum/ and there isn't one at /var/www/ (which I think is the root of my domain?). I'm trying to redirect to /forum/index.php?portal/ actually, but yeah same thing :p It worked fine on my old VPS, which confuses me why it doesn't work now.
  6. SniperBrob

    SniperBrob Member

    Any help? This is pretty urgent.
  7. Tracy Perry

    Tracy Perry Well-Known Member

    Do you have anything in the /var/www directory? If not, are you planning on putting a static page there or WordPress? If not, any particular reason why you placed it in /var/www/forums?
  8. SniperBrob

    SniperBrob Member

    @Tracy Perry Yes I have a few things in /var/www/. I have the following directories, forum (xenforo), stats (a stats page for my MC server), and then a bunch of php and css files.
  9. Tracy Perry

    Tracy Perry Well-Known Member

    What is the htaccess you have in your root (/var/www) directory. Odds are that is where the problem lay (and not with the .htaccess in the /var/www/forum - which you may need to uncomment the ReWriteBase on and replace /xenforo with /forum).
    If you don't have a .htaccesss in your root then what you are seeing is the expected behavior if your vhost definition points the domain at the /var/www folder. You can do a rewrite in the root htaccess to redirect all inbound traffic to the /forum folder.
  10. SniperBrob

    SniperBrob Member

    @Tracy Perry I put the .htaccess file in my root directory and uncommented the ReWriteBase line and replaced it to /forum. I'm still getting the error, so I'm assuming I have to do more still? Also in my /forum/ directory I still have the default htaccess file.
  11. Tracy Perry

    Tracy Perry Well-Known Member

    You don't put that one in your root one - only in your /forum one.
    As I said, it is expected behavior if your forum is not your http://mydomain.com root directory. It will default to displaying whatever is in /var/www (which is probably your root for the vhost) and you have to have either a page there with a link to it or have an htaccess written to redirect all incoming traffic to the /var/www/forum directory and then have links back to whatever the pages are in your /var/www directory.
    Are you using Apache2 or nginx. Can you post your related vhost definition (or is this a shared hosting environment?).
  12. SniperBrob

    SniperBrob Member

    @Tracy Perry Apache2. Sorry, I don't know what a vhost definition. If you haven't noticed, I'm an absolute amateur at this stuff. :p
  13. Tracy Perry

    Tracy Perry Well-Known Member

    Virtual Host - the definition for your site for apache to know where to go to find the goodies it needs.
    allows multiple sites to be hosted by one apache installation (like on one of my servers I have 7 sites hosted there).
    It's usually somewhere under /etc/httpd/conf if I remember correctly.
    It could be one file containing multiple definitions that look similar to
    # Ensure that Apache listens on port 80
    Listen 80
    # Listen for virtual host requests on all IP addresses
    NameVirtualHost *:80
    <VirtualHost *:80>
    DocumentRoot /www/example1
    ServerName www.example.com
    # Other directives here
    <VirtualHost *:80>
    DocumentRoot /www/example2
    ServerName www.example.org
    # Other directives here
    or it could be multiple individual vhost config files (which is what I do under nginx).
    Depending on which OS you are using it could be in different areas.

    Is this a shared hosting provider (which will limit what you can do) or a VPS/dedicated server?
  14. SniperBrob

    SniperBrob Member

    @Tracy Perry It's a VPS, and thanks I found it

    <VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  15. Tracy Perry

    Tracy Perry Well-Known Member

    OK, your root is /var/www, so now the question is... are you wanting anyone who goes to hossfactions.com to automatically route to the forum or do you have an index page being served from the root (an index.html, index.php, index.htm)?
    If you are wanting them to go directly to the forum, then you need to do an .htaccess with a redirect placed in your /var/www directory to route them to /var/www/forum when they arrive.

    You can try the below in the .htaccess and see if that works.

    RewriteEngine On
    RewriteRule ^$ /forum [L]
    The problem will be you will also need to decide if you want to re-route all WWW requests to the base domain (stripping the WWW) or vice-versa.
  16. SniperBrob

    SniperBrob Member

    I just want to have hossfactions.com take me to /forum/index.php?portal/ because I use xenporta
    Last edited: Mar 8, 2014
  17. Tracy Perry

    Tracy Perry Well-Known Member

    If you are using the built in routes, you just need it to take you to hossfactions.com/forum, which the supplied .htaccess code in your /var/www/.htaccess should do.
  18. SniperBrob

    SniperBrob Member

    I thought you told me to put the .htaccess in /forum/ not in the root? Anyways... should I just add
    RewriteRule ^$ /forum [L]
    to .htaccess in my root directory and I should be good to go?
  19. whynot

    whynot Well-Known Member

    Have you got cPanel?

    If you do:
    Domains > Redirects

    www. redirection: Only redirect with www. Redirect with or without www. Do Not Redirect www.
  20. SniperBrob

    SniperBrob Member

    whynot likes this.

Share This Page