Call a blog from a sub directory

Posted by Yosa Cs | Posted in | Posted on 3/27/2011 04:53:00 AM

0

From b2evolution manual
Jump to: navigation, search
Contents
[hide]

    * 1 This man page applies to b2evolution version "Phoenix"
          o 1.1 Prerequisite
          o 1.2 Moving blog B
                + 1.2.1 Linking back to the b2evo core files
                + 1.2.2 Telling b2evo about the new location
          o 1.3 Using several different subfolders

[edit] This man page applies to b2evolution version "Phoenix"

There are situations where you don't want all your blogs called from the same directory on your web server. This page explains how to achieve this.
[edit] Prerequisite



In order to understand the following, you should first get familiar with calling blogs through different files in the same directory.

Now let's assume we have this:

    * Blog A can be called through http://yoursite.net/a_stub.php
    * Blog B can be called through http://yoursite.net/b_stub.php

[edit] Moving blog B

Let's assume Blog A is fine where it is, but we'd like to call B through http://yoursite.net/subfolder/b_stub.php

Simply create a subfolder (named subfolder in this example) in the root of your webserver. Then move the file b_stub.php into this folder.

What happens if you try to call that file in its new location through http://yoursite.net/subfolder/b_stub.php ? You will get a PHP error saying **Fatal error**: [...] Failed opening required '[...]subfolder/b2evocore/_blog_main.php' !
[edit] Linking back to the b2evo core files

The error is because you moved the stub file b_stub.php out of its original location and now, when the stub file is called, it cannot find the b2evolution core files anymore.

To correct this, you will have to open the file b_stub.php again (watch out that you open the right one if you still have a copy in the old location!) and edit the line at the end of the file which says: require(dirname(__FILE__)."/b2evocore/_blog_main.php");

You must replace this line with: require(dirname(__FILE__)."/../b2evocore/_blog_main.php");

What we have done here is that we have added /.. in the relative path which leads from the stub file to the b2evo core files. /.. means "go back/up one folder. Thus if you had installed blog B in http://yoursite.net/subfolder1/subfolder2/b_stub.php -- which is two levels deeper than the normal location -- you would have needed to add /.. **two** times also, like this: require(dirname(__FILE__)."/../../b2evocore/_blog_main.php");

WARNING: be very careful not to erase the ?> at the end of the file. Also make sure you do not put any blank space after ?> : no spaces, no tabs, no new lines, no blank lines.

Save the file and upload it into /subfolder on your wbeserver if necessary. You can now call blog B in its new location.
[edit] Telling b2evo about the new location

Now, try to click on an internal link of the blog, for example try to access the latest comments. You will notice that b2evolution tries to call the file b_stub.php in its old location, ie *not* in the /subfolder !

In order to tell b2evolution that you want Blog B to be rooted in a subdirectory, you must go to the admin, under Blogs then select Blog B. Check that "Blog Folder URL:" is set to "relative to baseurl:", then enter the subfolder path in the input box on this line. You will notice that the base part of the URL is already known to b2evo. You just need to complete the URL by entering subfolder/.

Save your changes. Blog B is now fully operational in its new location.
[edit] Using several different subfolders

If you want, you can put each blog on your system in its own subfolder or nested subfolder tree by repeating the operation. But please note that you should never try to run a stub file at a level that is higher than the b2evo baseurl. b2evo is not designed for this. If necessary, simply set the baseurl as the root url of your website.

(The baseurl is set during the installation. It can be changed in the _config.php file. See advanced configuration .)

Comments Posted (0)

Posting Komentar

Silahkan berkomentar disini