apache下页面无样式,deploy了也没用
apache下页面无样式,deploy了也没用
经常有群友遇到,deploy了无数遍,但是页面还是没样式。
原来大多都是用的apache。
一般都是缺少.htaccess的原因
1,先检查下项目根目录/pub/static/.htaccess 是否可用
如果是在windows下,(隐藏文件 - 按cntrl + H查看文件)。
2,如果没这个文件的话,就创建.htaccess
该.htaccess的代码为:
php_flag engine 0 php_flag engine 0 # To avoid situation when web server automatically adds extension to path Options -MultiViewsRewriteEngine 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 ############################################ ## 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 xmlRewriteCond %{QUERY_STRING} !^$ RewriteRule ^(.*)$ %{REQUEST_URI}? [R=301,L] Header append Cache-Control public Header append Cache-Control no-store ############################################ ## Add default Expires header ## http://developer.yahoo.com/performance/rules.html#expires ExpiresActive On # Data ExpiresDefault "access plus 0 seconds" 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, htmlExpiresDefault "access plus 1 year" 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, flashExpiresDefault "access plus 1 year" 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" # FontsExpiresDefault "access plus 1 year" 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"
