b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Archives
  3. How to call a blog from a subdirectory?

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.

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

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' !

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.

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.

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 .)

Tags: archive
Created by fplanque • Last edit by fplanque on 2020-06-09 00:24 • •

On this page

  • This man page applies to b2evolution version "Phoenix"
  • Prerequisite
  • Moving blog B
  • Linking back to the b2evo core files
  • Telling b2evo about the new location
  • Using several different subfolders

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
  • Operations Reference
  • Advanced Topics
  • Glossary
  • Archives
    • Documentation Effort
    • How to call a blog from a subdirectory?
    • Converting WordPress Themes
    • Evoskin and A Template
    • Quick Upgrade Procedure
    • International Manuals
    • Known Issues
    • Online Help
    • Pretty URL
    • Pro WordPress Theme Conversion
    • Skin/Plugin XML Descriptions
    • Template Tag: Item Views
    • Version
    • How to Change the Appearance of my Permalinks
    • CVS / SourceForge
Run your own website!

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque