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

XF 1.3 Base url , wrong modrewrite subfolders

Discussion in 'XenForo Questions and Support' started by Andre Daub, Jul 14, 2014.

  1. Andre Daub

    Andre Daub Member

    Hi there,

    we just planing to move our project to a nother rootfolder/subfolders.
    But we have some problems of XenoForo to read the BaseUrl correct, so the CSS
    and links are not correct connected.

    We already found the problem in the ZEND Framework where the base url is created by the function
    setBaseUrl() Http.php.

    Our old folder roots are:
    myportal.com/ (wordpress)
    myportal.com/forum/ (xenoforo)

    New folders are:
    myportal.com/ (shop)
    myportal.com/_subportal/ (wordpress)
    myportal.com/_subportal/forum/ (xenoforo)

    We rewrite the access to Blog/Forum in this way:
    myportal.com/ (shop)
    myportal.com/blog/ (wordpress) ReWrite to => myportal.com/_subportal/
    myportal.com/forum/ (xenoforo) ReWrite to => myportal.com/_subportal/

    so the realy physical path is "myportal.com/_subportal/forum/" but we if we open the forum site over the rewrited path he can´t get the base url because he can´t find the correct path in the ZEND Framework:

    ZEND FRAMEWORK (http.php line 523)
    if (empty($basename) || !strpos($truncatedRequestUri, $basename)) {
    // no match whatsoever; set it blank
    $this->_baseUrl = '/forum';
    return $this;

    Is it possible to set the BaseUrl in the config or other way(but not hardcoded)

    We already tryed this from your FAQ:
    $config['internalDataPath'] = 'forum';
    $config['externalDataUrl'] = 'forum';

    In the admin interface in settings from the forum we set the site url to:

    When we open the AdminPanel over the realy physical url all is fine and in example
    the <base href="http://myportal.com/_subportal/forum/" /> is correct setted and
    all works.

    Hope you can help us!
  2. Mike

    Mike XenForo Developer Staff Member

    I suspect that you need to set the RewriteBase line in this case (to /forum).
  3. Andre Daub

    Andre Daub Member

    We added this before but had no effect. Tryed "/forum" and "/forum/" the base url seems always linked to "http://myportal.com"

    This is our htaccess in XenoForo Folder myportal.com/_subportal/forum/:

    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 /forum

    # 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]
    Last edited: Jul 14, 2014
  4. Mike

    Mike XenForo Developer Staff Member

    I'm not clear how you're doing the "rewrite" to get rid of _subportal in the URL, but it is breaking the detection of the part of URL that represents the directory we're in. I'm not sure I see the advantage of what you're trying to do -- you should just be able to create the blog directory and move WP in there. (You already have XF in the forum directory so nothing to change there.)

    Otherwise, you'll be looking at manipulating some $_SERVER variables to "fake" the URL that you need or hacking the base URL function that you've identified to fit your script (or setting the base URL manually by calling setBaseUrl() on the request object).
  5. Andre Daub

    Andre Daub Member

    Hi Mike,

    yes we already overwrite the SUPERGLOBALS but this conflicts with other function where include happens.
    The only way we found is to set the baseurl in the function hardcoded, but we tryed to find a solution that we
    can change this in config because of upcoming XenoForo updates in the future.

    But then we try to include and change this in other way, thankyou for your help, here our ReWrite for the forum:
    (from root myportal.com/ )
    # ==================== Forum
    RewriteCond %{HTTP_HOST} ^myportal\.com$
    RewriteCond %{REQUEST_URI} ^/forum/.*
    # means that if the file with the specified name/folder doesn´t exist then procede to the rewrite rule below
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # set subfolder to root
    RewriteRule ^forum/(.*)$ /\_subportal/forum/$1
  6. Andre Daub

    Andre Daub Member

    With this code line in the config.php it seams to work in the frontend:
    $_SERVER['SCRIPT_NAME'] = '/forum/index.php'; // real path /_subportal/forum/index.php

    On AdminPanel CSS only work if i call the real path "/_subportal/forum/admin.php" but thats ok

    link rel="stylesheet" href="admin.php?_css/xxxxxxxxxxxxxxxxxxx
  7. Mike

    Mike XenForo Developer Staff Member

    Unfortunately, since you're doing that rewrite, you're not actually hitting XenForo's own rewrites and thus changing the assumptions made by the system. Other than custom code modifications, I don't think I could make a particular recommendation.

    I still don't see why the forum needs to go through this system, versus just having a forum directory in the root.

Share This Page