2017-06-14 149 views
0

我們在Linux和Apache上運行Laravel 5.4。以下錯誤一下子就被顯示出來在/var/log/httpd/error_log,但對我們.htaccess文件所做的更改:命令'text/css'無效,可能是拼寫錯誤或未包含在服務器配置中的模塊定義的

/var/www/html/public/.htaccess: Invalid command 'text/css', perhaps misspelled or defined by a module not included in the server configuration 

整個.htaccess文件看起來是這樣的:

<IfModule mod_expires.c> 

    ExpiresActive on 
    ExpiresDefault          "access plus 1 month" 

    # CSS 
    ExpiresByType text/css        "access plus 1 year" 

    # Data interchange 
    ExpiresByType application/json      "access plus 0 seconds" 
    ExpiresByType application/xml      "access plus 0 seconds" 
    ExpiresByType text/xml        "access plus 0 seconds" 

    # Favicon (cannot be renamed!) 
    ExpiresByType image/x-icon       "access plus 1 week" 

    # HTML components (HTCs) 
    ExpiresByType text/x-component      "access plus 1 month" 

    # HTML 
    ExpiresByType text/html        "access plus 0 seconds" 

    # JavaScript 
    ExpiresByType application/javascript    "access plus 1 year" 
    ExpiresByType application/x-javascript    "access plus 1 year" 

    # Manifest files 
    ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" 
    ExpiresByType text/cache-manifest     "access plus 0 seconds" 

    # Media 
    ExpiresByType audio/ogg        "access plus 1 month" 
    ExpiresByType image/gif        "access plus 1 month" 
    ExpiresByType image/jpeg       "access plus 1 month" 
    ExpiresByType image/png        "access plus 1 month" 
    ExpiresByType video/mp4        "access plus 1 month" 
    ExpiresByType video/ogg        "access plus 1 month" 
    ExpiresByType video/webm       "access plus 1 month" 

    # Web feeds 
    ExpiresByType application/atom+xml     "access plus 1 hour" 
    ExpiresByType application/rss+xml     "access plus 1 hour" 

    # Web fonts 
    ExpiresByType application/font-woff2    "access plus 1 month" 
    ExpiresByType application/font-woff     "access plus 1 month" 
    ExpiresByType application/vnd.ms-fontobject   "access plus 1 month" 
    ExpiresByType application/x-font-ttf    "access plus 1 month" 
    ExpiresByType font/opentype       "access plus 1 month" 
    ExpiresByType image/svg+xml       "access plus 1 month" 

</IfModule> 

<IfModule mod_rewrite.c> 

    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

    # Redirect Trailing Slashes If Not A Folder... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)/$ /$1 [L,R=301] 

    # Force traffic through https 
    # RewriteCond %{HTTPS} on 

    # Redirect non-www urls to www 
    # Force through www for SSL certificate coverage (except IP) 
    RewriteCond %{HTTP_HOST} !^[0-9]+\. 
    RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ 
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 

    # Handle Authorization Header 
    RewriteCond %{HTTP:Authorization} . 
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

    # End of Apache Rewrite Rules 

</IfModule> 

# BEGIN Compression 
<IfModule mod_filter.c> 

    AddOutputFilterByType DEFLATE application/atom+xml 
    AddOutputFilterByType DEFLATE application/javascript 
    AddOutputFilterByType DEFLATE application/json 
    AddOutputFilterByType DEFLATE application/ld+json 
    AddOutputFilterByType DEFLATE application/manifest+json 
    AddOutputFilterByType DEFLATE application/rdf+xml 
    AddOutputFilterByType DEFLATE application/rss+xml 
    AddOutputFilterByType DEFLATE application/schema+json 
    AddOutputFilterByType DEFLATE application/vnd.geo+json 
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject 
    AddOutputFilterByType DEFLATE application/x-font-ttf 
    AddOutputFilterByType DEFLATE application/x-javascript 
    AddOutputFilterByType DEFLATE application/x-web-app-manifest+json 
    AddOutputFilterByType DEFLATE application/xhtml+xml 
    AddOutputFilterByType DEFLATE application/xml 
    AddOutputFilterByType DEFLATE font/eot 
    AddOutputFilterByType DEFLATE font/opentype 
    AddOutputFilterByType DEFLATE image/bmp 
    AddOutputFilterByType DEFLATE image/svg+xml 
    AddOutputFilterByType DEFLATE image/vnd.microsoft.icon 
    AddOutputFilterByType DEFLATE image/x-icon 
    AddOutputFilterByType DEFLATE text/cache-manifest 
    AddOutputFilterByType DEFLATE text/css 
    AddOutputFilterByType DEFLATE text/html 
    AddOutputFilterByType DEFLATE text/javascript 
    AddOutputFilterByType DEFLATE text/plain 
    AddOutputFilterByType DEFLATE text/vcard 
    AddOutputFilterByType DEFLATE text/vnd.rim.location.xloc 
    AddOutputFilterByType DEFLATE text/vtt 
    AddOutputFilterByType DEFLATE text/x-component 
    AddOutputFilterByType DEFLATE text/x-cross-domain-policy 
    AddOutputFilterByType DEFLATE text/xml 

</IfModule> 
# END of Compression 
+0

您是否能夠將此錯誤與訪問日誌中的請求相匹配?你是否收到每個CSS文件請求的錯誤?如果'.htaccess'文件產生這個錯誤,那麼你會看到一個500(內部服務器錯誤)響應。 FWIW你的'.htaccess'文件「看起來」確定。 (任何奇怪的隱藏字符?) – MrWhite

+0

@ user82217我能夠在'access_log'中找到一個匹配時間戳和500錯誤響應的請求。它看起來好像來自一個URI(請求所有的錯誤昨天都有500個錯誤),但是,即使頁面已經被訪問,它也沒有被觸發。如果它回來,我們會密切關注它。 – Taylor

回答

0

我們能夠找到的匹配要求/var/log/httpd/access_log爲每個「無效命令」錯誤:

[14/Jun/2017:09:11:05 -0500] "GET /register HTTP/1.1" 500 527 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36" 

此錯誤未發生從昨天早上起甚至在頁面被訪問之後。我們清除了緩存,刪除了所有會話,並在發佈原始問題後不久重新啓動服務器。

-1

今天我也有這個錯誤,同時建立一個新的開發環境。在嘗試了所有我能找到的東西之後,我終於偶然發現了一篇文章,指出過濾器塊中有太多行。從文章:

症狀

網站無法打開,顯示500錯誤類型。

有一個在/var/www/vhosts/example.com/logs/error_log文件類似這樣的記載:

[核心:警報] /var/www/vhosts/example.com/httpdocs /.htaccess:無效命令「文本/ CSS」,也許不包含在服務器配置

原因

太長.htaccess文件的AddOutputFilterByType表達的聲明的模塊拼錯或定義。

請參閱下面的資源獲取更多信息:

https://github.com/ezekg/theme-juice-vm/issues/4 http://mail.blueonyx.it/pipermail/blueonyx/2010-April/004320.html

分辨率

修改的部分,所以它看起來類似於:

<IfModule mod_filter.c> 
AddOutputFilterByType DEFLATE "application/atom+xml" "application/javascript" "application/json" "application/ld+json" "application/manifest+json" "application/rdf+xml" "application/rss+xml" "application/schema+json" "application/vnd.geo+json" "application/vnd.ms-fontobject" "application/x-font-ttf" "application/x-javascript" "application/x-web-app-manifest+json" "application/xhtml+xml" "application/xml" "font/eot" "font/opentype" "image/bmp" "image/svg+xml" "image/vnd.microsoft.icon" "image/x-icon" "text/cache-manifest" "text/css" "text/html" "text/javascript" "text/plain" "text/vcard" "text/vnd.rim.location.xloc" "text/vtt" "text/x-component" "text/x-cross-domain-policy" "text/xml" 
</IfModule> 

它在我的情況下工作。

相關問題