Hello,
I just moved my current flarum installation from a subdomain to a subdirectory path. The main index.php works, but the .css and .js won't load. (404 Error).
All the files from the public directory are now one layer up, where the other configs like config.php and flarum are. I changed the index.php and site.php to fix the paths. (According to this guide)
I haven't changed the Nginx config aside from adding the subfolder route.
My Nginx config
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/forum;
server_name example.com/forum; # Changed from actual domain to example for this post
include /var/www/forum/.nginx.conf;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
}
The Flarum nignx file:
# Pass requests that don't refer directly to files in the filesystem to index.php
location /forum {
try_files $uri $uri/ /index.php?$query_string;
}
# The following directives are based on best practices from H5BP Nginx Server Configs
# https://github.com/h5bp/server-configs-nginx
# Expire rules for static content
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
add_header Cache-Control "max-age=0";
}
location ~* \.(?:rss|atom)$ {
add_header Cache-Control "max-age=3600";
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc)$ {
add_header Cache-Control "max-age=2592000";
access_log off;
}
location ~* \.(?:css|js)$ {
add_header Cache-Control "max-age=31536000";
access_log off;
}
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
add_header Cache-Control "max-age=2592000";
access_log off;
}
# Gzip compression
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
Edit: I forgot to mention my Flarum version, etc.
Flarum core 0.1.0-beta.13
PHP version: 7.3.19-1~deb10u1
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, pcntl, Reflection, SPL, session, sodium, standard, mysqlnd, PDO, xml, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd, gettext, iconv, json, exif, mysqli, pdo_mysql, Phar, posix, readline, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xmlreader, xmlwriter, xsl, zip, Zend OPcache
+---------------------------------+----------------+--------+
| Flarum Extensions | | |
+---------------------------------+----------------+--------+
| ID | Version | Commit |
+---------------------------------+----------------+--------+
| flarum-approval | v0.1.0-beta.13 | |
| flarum-bbcode | v0.1.0-beta.12 | |
| flarum-emoji | v0.1.0-beta.13 | |
| flarum-lang-english | v0.1.0-beta.13 | |
| flarum-flags | v0.1.0-beta.13 | |
| flarum-likes | v0.1.0-beta.13 | |
| flarum-lock | v0.1.0-beta.13 | |
| flarum-markdown | v0.1.0-beta.13 | |
| flarum-mentions | v0.1.0-beta.13 | |
| flarum-statistics | v0.1.0-beta.13 | |
| flarum-sticky | v0.1.0-beta.13 | |
| flarum-subscriptions | v0.1.0-beta.13 | |
| flarum-suspend | v0.1.0-beta.13 | |
| flarum-tags | v0.1.0-beta.13 | |
| cbmainz-de | 0.12.1 | |
| fof-polls | 0.1.2 | |
| nomiscz-auth-steam | v0.1.7 | |
| michaelbelgium-discussion-views | v4.0.1 | |
| fof-upload | 0.10.0 | |
| fof-auth-discord | 0.1.3 | |
| v17development-seo | 1.2.1 | |
| fof-sitemap | 0.5.3 | |
| fof-user-directory | 0.3.4 | |
| clarkwinkelmann-circle-groups | 0.2.1 | |
+---------------------------------+----------------+--------+
Base URL: https://example.com/forum
Installation path: /var/www/forum
Debug mode: off