maybe like a this ?

http://prntscr.com/b6znn2

You need add virtual host to /etc/apache2/sites-available/default.conf

 <VirtualHost *:80>
 ServerName forum.example.com
 DocumentRoot /var/www/forum.example.com
 <Directory "/var/www/forum.example.com">
      AllowOverride All
 </Directory>
 </VirtualHost>

and add http://forum.example.com to config.php

Weeboo Huh, interesting! I'm on a shared host unfortunately and don't have a default.conf file, I think because a shared host has limited access to Apache options. Can this be overridden in .htaccess?

You have access to the root?
I use .htaccess to drive to the folder forum.example.com

    You can try just to the root directory, add .htaccess file

    Redirect 301 / http://forum.example.com/

    then make a folder forum.example.com and add files flarum

    jordanjay29 The .htaccess of forum.mydomain.com is empty ... everything is in the .htaccess of forum.mydomain.com/flarum:

    # Allow access if Flarum is installed in a subdirectory,
    # but another .htaccess in a higher directory denies access.
    
    <IfModule mod_authz_core.c>
      Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
      Order Allow,Deny
      Allow from all
    </IfModule>
    
    <IfModule mod_rewrite.c>
      RewriteEngine on
    
      RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
      RewriteRule ^vendor/(.*)?$ / [F,L]
      RewriteRule ^storage/(.*)?$ / [F,L]
      RewriteRule ^config.php$ / [F,L]
    
      RewriteRule ^api(.*)$ api.php [QSA,L]
      RewriteRule ^admin(.*)$ admin.php [QSA,L]
    
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule !^assets index.php [QSA,L]
    
      # MultiViews can mess up our rewriting scheme
      Options -MultiViews
    
      # Autoindex will list all assets files which is not so good
      Options -Indexes
    </IfModule>
    
    <IfModule mod_deflate.c>
      # Compress all output labeled with one of the following MIME-types
      <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE application/atom+xml \
                                      application/javascript \
                                      application/json \
                                      application/vnd.ms-fontobject \
                                      application/x-font-ttf \
                                      application/x-web-app-manifest+json \
                                      application/xhtml+xml \
                                      application/xml \
                                      font/opentype \
                                      image/svg+xml \
                                      image/x-icon \
                                      text/css \
                                      text/html \
                                      text/plain \
                                      text/xml
      </IfModule>
    </IfModule>
    
    # Configure cache expiry for different file types
    <IfModule mod_expires.c>
      ExpiresActive on
      ExpiresDefault                                      "access plus 1 second"
    
      ExpiresByType text/css                              "access plus 1 year"
      ExpiresByType application/json                      "access plus 0 seconds"
      ExpiresByType application/xml                       "access plus 0 seconds"
      ExpiresByType text/xml                              "access plus 0 seconds"
      ExpiresByType image/x-icon                          "access plus 1 week"
      ExpiresByType text/html                             "access plus 0 seconds"
      ExpiresByType application/javascript                "access plus 1 year"
      ExpiresByType application/x-web-app-manifest+json   "access plus 0 seconds"
      ExpiresByType text/cache-manifest                   "access plus 0 seconds"
      ExpiresByType image/gif                             "access plus 1 month"
      ExpiresByType image/jpeg                            "access plus 1 month"
      ExpiresByType image/png                             "access plus 1 month"
      ExpiresByType application/atom+xml                  "access plus 1 hour"
      ExpiresByType application/rss+xml                   "access plus 1 hour"
      ExpiresByType application/font-woff2                "access plus 1 month"
      ExpiresByType application/font-woff                 "access plus 1 month"
      ExpiresByType application/vnd.ms-fontobject         "access plus 1 month"
      ExpiresByType application/x-font-ttf                "access plus 1 month"
      ExpiresByType font/opentype                         "access plus 1 month"
      ExpiresByType image/svg+xml                         "access plus 1 month"
    </IfModule>

    I think I see where you're going with this; the .htaccess in the root of the site is denying access?

    Try adding this to your .htaccess on the root of the forum.mydomain.com.

    Edit: the forum doesn't like special formatting. Use this pastebin as the example:

    Replace the "mydomain" on the RewriteCond with your main domain name.

      amiller030 Thanks for the suggestion. When I replaced the root .htaccess with your example (substituting in the domain for mydomain.com) I get the following error on forum.mydomain.com:

      Cannot GET http://forum.mydomain.com/

      Any idea what's going on here?

      Weeboo I'm not sure I understand what you mean. Do you mean I can't do this through .htaccess, but instead need to edit the Apache config file?

      Weeboo Sorry, I still don't really understand what you mean. Do you mean a virtual host as in a VPS? Or is there a way to add a virtual host on a shared server?

      best if you gave the name of your domain, then I'll try to help you

      Sorry, I'm not willing to post a domain that I'm working on to a public forum. I don't see why forum.example.com or similar isn't sufficient, I just need to understand what you're suggesting I do with the .htaccess file, and whether I can do this on a shared server or you're saying it's only possible with a VPN.

      electrolyte Can you provide some more details of what exactly "doesn't work" after trying to move to the root directory and changing the config file? It's hard to guess...

      I'm reasonably sure that once we have more information, this will be easy to solve.

        Franz Hey Franz, thanks for your reply. My config.php file was originally:

        <?php return array (
          'debug' => true,
          'database' => 
          array (
            'driver' => 'mysql',
            'host' => '[hostname]',
            'database' => '[dbname]',
            'username' => '[dbun]',
            'password' => '[dbpw]',
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => 'forum_',
            'strict' => false,
          ),
          'url' => 'http://forum.mydomain.com/flarum',
          'paths' => 
          array (
            'api' => 'api',
            'admin' => 'admin',
          ),
        );

        When I change the url to 'url' => 'http://forum.mydomain.com', the forum.mydomain.com/flarum 404s, but there is nothing at forum.mydomain.com.

        I'm trying to keep the forum at forum.mydomain.com/flarum, but have users able to access it by visiting forum.mydomain.com.

        Let me know if the above is unclear. Thanks again!

          electrolyte Hmm, sorry to sound a bit pessimistic, but off the top of my head there's no easy solution for this, and certainly not one built into Flarum's core.

          I must say, though, that having the forum available under two different URLs is problematic for multiple reasons, search engine optimization (no duplicate URLs!) being an important one. Why do you want to do this in the first place?

          A better way might be to go for one location, and then build a simple redirect from the other location.

            Franz That was my first instinct, to change my host's default web directory from forum.mydomain.com to forum.mydomain.com/flarum. I have done this many times with sites in the past; it's a good way to keep big sites in a subfolder and the root domain organised (ie when it's a big Wordpress install, or similar). This usually does involve some database editing because the DB will reference the subdomain, but I don't know what the case is with Flarum. Just changing the default web directory made everything inaccessible.

            I thought about just moving everything to the root of the site, but I don't know what effect this would have on the existing database or if it would even continue to work, hence my original question. If I move everything to root will I have to edit the SQL file for the DB? Should I just nuke everything and clean install?