• Support
  • Add More URL in the installation

I wanted to know how I'd like to add more domains to the same installation. The way I'm doing is not working

<?php return array (
  'debug' => false,
  'database' => 
  array (
    'driver' => 'mysql',
    'host' => 'localhost',
    'database' => '',
    'username' => '',
    'password' => '',
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'port' => '3306',
    'strict' => false,
  ),
  'url' => 'https://URL1',
  'url' => 'https://URL2',
  'paths' => 
  array (
    'api' => 'api',
    'admin' => 'admin',
  ),
);

    ram0ng1 what are you trying to achieve ? The forum should only have one canonical url. You should setup HTTP redirects from alternate domains. There's no multitenancy built in.

    You can dynamically set the url property but there are very few reasons to actually have to do that.

      ram0ng1 I think that config.php is based on Beta 7.1 and below. In Beta 8 we do not use path anymore.

      clarkwinkelmann This is not exactly right. Though Flarum does not support "multi tenancy" out of box, Flarum is made ready for its extension if anybody wants to do it.

      There are few discussions on that already and the key answer lies in one of @luceos post in there but for separate databases.

      I am currently running several urls in one installation and in a single database based on that (I mentioned this in one of the discussions) and in the process of learning how to do a proper extension for it.

        ahrasis I meant, without adding extensions or code customization, there shouldn't be any reason to have multiple urls resolve to your standard Flarum install. Of course Flarum extensibility allows for multitenancy (using the term very broadly here as there are many options) experience, just not out of the box.

        Indeed the OP didn't say which version of Flarum it was. But I don't think the working behind the url property changed between beta 7 and 8. It's still the canonical url of the forum.

        @clarkwinkelmann I just wanted my forum to be accessed through other URLs there is not that standard set
        I just wanted to allow access to other urls
        ahrasis how did you do to run multiple urls with one install?

          ram0ng1

          1. You need to modify config.php accordingly. As I already mentioned, this was suggested by @luceos post #4 and post #5 in Multisite installation thread for creating multi forum with multi url and multi database i.e. each shall use their own database. Please follow and read the links if this is what you want.

          2. However, what I have in mind and want to achieve is different than what @luceos proposed as I want to do something like what I mentioned in my post in Multi-language content thread which is multi forum with one installation in a single database.

          Here is a sample of the hack that is being made to my config.php:

          <?php
          
          if (isset($_SERVER['SERVER_NAME'])) {
          	$tenancy_url = $_SERVER['SERVER_NAME'];
          	$tenancy_url_filter = array('discuss.flarum.org', 'english.flarum.org', 'spanish.flarum.org', 'french.flarum.org');
          }
          
          return array (
            'debug' => false,
            'database' => 
            array (
              'driver' => 'mysql',
              'host' => 'localhost',
              'database' => 'dbname',
              'username' => 'dbusername',
              'password' => 'dbpassword',
              'charset' => 'utf8mb4',
              'collation' => 'utf8mb4_unicode_ci',
              'prefix' => 'flarumprefix_',
              'port' => '3306',
              'strict' => false,
            ),
          
            'url' => 'https://' . (isset($_SERVER['SERVER_NAME']) && in_array($tenancy_url, $tenancy_url_filter) ? $tenancy_url : 'discuss.flarum.org'),
            
          );

          *As I said "the path in config.php" for Beta 7.1 below and Beta 8.0 above is different as in the later, you don't need to set the api and admin path in config.php anymore and it should work without it being set in there, as they are already set elsewhere.

          **I also clarified and gave my sample structure in a post #13 in Multisite installation thread; where to achieve the same, other than you need to configure the config.php as stated above, you will need to create vhost / conf for each urls as well.

          ***The above can surely be done better with an extension to check $tenancy_url against $tenancy_url_filter from a created table in the database without modifying config.php.

            No problem. Hopefully I can get a working extension for this later.