How to call a blog from a subdirectory?
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.
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
- Blog B can be called through
Moving blog B
Let’s assume Blog A is fine where it is, but we’d like to call B through
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' !
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:
You must replace this line with:
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:
‘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.
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
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
Save your changes. Blog B is now fully operational in its new location.
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 Collections Tab .)
Created by • Last edit by on Oct 08, 2015