I had a similar issue on a site just recently. I still don’t know quite what the underlying cause was, but deleting the vendor directory completely and running a composer install cleared it up.
What version are you using? I checked a 4.6.1 install I have and this is the .htaccess file contents for the file in /public
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Files>
# Deny access to IIS configuration
<Files web.config>
Order deny,allow
Deny from all
</Files>
# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
</Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
<IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
<IfModule mod_dir.c>
DirectoryIndex disabled
DirectorySlash On
</IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase '/public'
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule ^\.env - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
RewriteRule (error|silverstripe|debug)\.log - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
# Try finding framework in the vendor folder first
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
</IfModule>
### SILVERSTRIPE END ###
Using a .htaccess file from a different version of SS could cause issues.
Assuming it’s safe to experiment (you have source control set up etc.) I would try making these changes to your composer.json file:
Change “silverstripe/recipe-cms”: “4.3.3@stable” to “silverstripe/recipe-cms”: “^4.6”
Delete the “app/.htaccess”, line from the “extra” section
Delete the whole “public-files-installed” section
Then run composer update and see what happens. It should hopefully upgrade you to the latest stable version of Silverstripe, and reset your htaccess files.
I had this exact problem. It turned out that the dist folder was like a broken symlink or not uploaded correctly. I had to reinstall the Silverstripe Framework to fix it.
I have the same problem when I was downloading the Silverstripe 4.9 through composer command and executing this command code vendor/bin/sake dev/build on the termenal after the dev/build process then I browsed my-site the CSS and Javascript did not rendered properly – Aaaarrgghh!.
What I did. I run the composer expose and composer update still didnt work. I also deleted the vendor folder and run the composer install and now i am getting a problem Autoloading is missing. However, I decided to redownload the SS4.9 and configuring properly the .env fle and then run the dev/build on the browser instead on the terminal. Finally, its work amazing!.. So i move my project into public instead using the Theme.