CSS Doesn't Load After Migration of Magento Website

CSS doesn't load after migration of magento website

Sounds like an issue with your .htaccess file. Minification rewrites are handled there. If you haven't already, make sure your .htaccess file came over in the transfer, and make the appropriate changes if directories or anything else has been changed.

Styles not loading in magento due to wrong url path, how to solve this?

Friends i have solved the problem..

i redid all the steps that i have done before, like getting all the files from svn, re-importing the database, and changing the web/unsecure/base_url & web/secure/base_url, configuring apache virtual hosts etc..

but i think what solved the problem was changing the ownership of media and var directories to www-data instead of kaushik and giving those folders full permissions.

I have done this step because in the main server, the those directories were owned by www-data user..

Also, i observed that the css was loading from se.com/media/css folder, which was automatically created once the media directory was setup properly, which did not happen earlier, the directory has css files like 0a039da6028e6d636132ecd5e235f417.css etc..

the request url was something like this (from net window in firebug)...

http://se.com/media/css/0a039da6028e6d636132ecd5e235f417.css 

and not like the one i mentioned how it should be above (http://se.com/skin/frontend/default/jm_wall/css/layout.css), nor like how the request was sent (http://se.com/var/www/se.com/skin/frontend/default/jm_wall/css/layout.css)

Hope this helps someone else...

Product images not showing after migration of magento website

Just in case anyone else has the same problem, removing the .htaccess in the media folder did the trick. I don't know if that's the best possible solution though! Thanks!

Magento 2.4.1 - Moved site to a subdirectory - CSS & JS Broken - cleared Cache still broken [SOLVED]

On comparing the 2 directories (I renamed it) I noticed the /var/static2/ directory contained a .htaccess file which my newly created directory did not. Upon moving the .htaccess to the new static directory my issue was fixed.

Hopefully this will help someone else who has this issue - as the .htaccess file does not seem to be regenerated with the directory automatically?

Copy of the .htaccess (version 2.4.1)

<IfModule mod_php5.c>
php_flag engine 0
</IfModule>

<IfModule mod_php7.c>
php_flag engine 0
</IfModule>

# To avoid situation when web server automatically adds extension to path
Options -MultiViews

<IfModule mod_rewrite.c>
RewriteEngine On

## you can put here your pub/static folder path relative to web root
#RewriteBase /magento/pub/static/

# Remove signature of the static files that is used to overcome the browser cache
RewriteRule ^version.+?/(.+)$ $1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* ../static.php?resource=$0 [L]
# Detects if moxieplayer request with uri params and redirects to uri without params
<Files moxieplayer.swf>
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(.*)$ %{REQUEST_URI}? [R=301,L]
</Files>
</IfModule>

############################################
## setting MIME types

# JavaScript
AddType application/javascript js jsonp
AddType application/json json

# HTML

AddType text/html html

# CSS
AddType text/css css

# Images and icons
AddType image/x-icon ico
AddType image/gif gif
AddType image/png png
AddType image/jpeg jpg
AddType image/jpeg jpeg

# SVG
AddType image/svg+xml svg

# Fonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf
AddType application/x-font-otf otf
AddType application/x-font-woff woff
AddType application/font-woff2 woff2

# Flash
AddType application/x-shockwave-flash swf

# Archives and exports
AddType application/zip gzip
AddType application/x-gzip gz gzip
AddType application/x-bzip2 bz2
AddType text/csv csv
AddType application/xml xml

<IfModule mod_headers.c>

<FilesMatch .*\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$>
Header append Cache-Control public
</FilesMatch>

<FilesMatch .*\.(zip|gz|gzip|bz2|csv|xml)$>
Header append Cache-Control no-store
</FilesMatch>

</IfModule>

<IfModule mod_expires.c>

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

ExpiresActive On

# Data
<FilesMatch \.(zip|gz|gzip|bz2|csv|xml)$>
ExpiresDefault "access plus 0 seconds"
</FilesMatch>
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType text/csv "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/zip "access plus 0 seconds"
ExpiresByType application/x-gzip "access plus 0 seconds"
ExpiresByType application/x-bzip2 "access plus 0 seconds"

# CSS, JavaScript, html
<FilesMatch \.(css|js|html|json)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/html "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/json "access plus 1 year"

# Favicon, images, flash
<FilesMatch \.(ico|gif|png|jpg|jpeg|swf|svg)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"

# Fonts
<FilesMatch \.(eot|ttf|otf|svg|woff|woff2)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-otf "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"

</IfModule>

I am getting 404 error for css and js files after I installed magento

Hi @Silverwolf96 and welcome on StackOverflow.

There are few things you can try/check.

1.) Check in the page source if the URLs to your files are correct. If not set correctly, set them manually as described in step 2.

2.) Go to Store > Configuration > General > Web and set under Base URLs & Base URLs (Secure) your URLs for static files - you can set this URL manually and it needs to be set as http://www.example.com/static/

3.) You can try to remove pub/static/frontend on the server

4.) Check what happens if you select Magento Luma as the default theme



Related Topics



Leave a reply



Submit