2

I have downloaded and installed Magento 2 but I'm getting 404 error for scripts and css. An example of my image path is: http://www.arredomobilionline.com/pub/static/frontend/Magento/luma/it_IT/images/logo.svg

I've already tried this solution:

Open up app/etc/di.xml and find the virtualType name="developerMaterialization" section. In that section you'll find an item name="view_preprocessed" that needs to be modified or deleted. You can modify it by changing the contents from Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink to Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

inside my deafult di.xml file as default there's:

 <virtualType name="developerMaterialization" type="Magento\Framework\App\View\Asset\MaterializationStrategy\Factory">
 <arguments>
 <argument name="strategiesList" xsi:type="array">
 <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
 <item name="default" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item>
 </argument>
 </arguments>
</virtualType>

I tried to delete the first symlink part or change it into "copy" but it's not working.

asked Nov 23, 2015 at 9:32
2
  • What mode are you operating in? Default, developer or production? And did you run the static-deploy tool? Commented Nov 24, 2015 at 23:27
  • I think default, I downloaded magento 2 from the Magento website and I didn't change settings. As for the static-deploy tool I'm trying to understand how it works Commented Nov 25, 2015 at 8:09

8 Answers 8

3

I had the similar problem that css was not loading and admin give 404 so that Please check that mod_rewrite module is enable in server.

answered Nov 23, 2015 at 11:28
1
  • I've checked my htaccess and there's: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^arredomobilionline\.com$ [NC] RewriteRule ^(.*)$ arredomobilionline.com/1ドル [R=301,L] Commented Nov 23, 2015 at 13:17
2
  1. Change "Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink" to "Magento\Framework\App\View\Asset\MaterializationStrategy\Copy" in app/etc/di.xml file (line 598)
  2. Run via ssh: php bin/magento setup:static-content:deploy
  3. Next command: chmod -R 777 pub/*
  4. And finally: rm -rf var/*

This steps works fine for me ; )

answered Feb 15, 2016 at 18:36
1
  • Can changing this <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</item> bring any performance problems as our site is running very slow? Commented Apr 1, 2017 at 7:57
2

I had the same problem. This command works for me

php bin/magento setup:static-content:deploy
answered Feb 15, 2016 at 18:39
1
answered Nov 23, 2015 at 9:40
1
  • I've set 777 permission to every file Commented Nov 23, 2015 at 13:30
1

give full permission for pub/static folder and run below php script

php D:\xampp\htdocs\magento2ee\bin\magento setup:static-content:deploy

(mention path is my local system and i run the script after going to php folder )

answered Nov 24, 2015 at 5:59
1
  • is it working fine in local setup?? Commented Dec 21, 2015 at 13:47
0

First, Check if the CSS and JS files have proper permissions. Then clear var/cache, var/page_cache and var/generation folders.

The try to run this command: magento setup:static-content:deploy - more details on this command are available here- http://devdocs.magento.com/guides/v2.0/config-guide/cli/config-cli-subcommands-static-view.html

Now run your frontend URL. JS and CSS files should start coming now.

Hope this helps !!

answered Nov 23, 2015 at 10:05
0

add "Copy" instead of "copy" it will work

0
0

I had a similar issue with the store of a client. The problem was that Apache isn't following symlinks on this hosting environment. It returns 403 forbidden for symlinked static content files.

A workaround solution was to switch to production mode.

bin/magento deploy:mode:set production

answered Mar 5, 2021 at 14:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.