0

I've recently performed a Magento security scan and it recommended I move the root of my Magento 2 installation to the pub directory.

I've followed the instructions here but I've had no success. The site fails to find the images and merged CSS files. I have double checked that the CSS files and images exist in their respective directories in pub/static.

My Apache configuration:

DocumentRoot /var/www/html/magento2/pub
ServerName www.somedomainorother.co.uk
ServerAlias somedomainorother.co.uk

<Directory "/var/www/html/magento2/">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>

I am using Apache 2.4, Centos 7.3.

Has anybody run across a problem like this before and how did you fix it?

Jack Hughes
  • 5,514
  • 4
  • 27
  • 32

2 Answers2

3

I had exactly the same issue and the root cause I found that Magento was still looking for the static resources under [site_url]/pub/static or (if static versioning is enabled):

[site_url]/version[NNNNNN]/pub/static

While they should have been requested according to the new root

[site_url]/version[NNNNNN]/static

I had to check the static and media urls, in core_config_data I found [site_url]/pub/media and [site_url]/pub/static as values for base_media_url, base_static_url for secure and unsecure. I simply removed these config records from core_config_data and left the application to retrieve them correctly by default.

laurent
  • 418
  • 3
  • 7
1

I assume you have tried the usual trick of:

php bin/magento setup:static-content:deploy

You may need to add an '-f' after depending on which mode you are in. Also, if you are using a language different to 'en_US' then you woul dneed to add that at the end. I have to do this:

php bin/magento setup:static-content:deploy -f en_GB

This has helped me get out of those CSS and image screw ups.

Otherwise I would look at maybe it being a permissions issue?

ezkirk
  • 11
  • 3