我試圖在Apache2 web服務器上設置expires HTTP加熱器,但是我所做的每一次嘗試都沒有影響或崩潰站點。我試圖在我的VirtualHost
上添加expires標頭設置,如下所示,但是這會導致網站崩潰。我不明白這是爲什麼?試圖設置HTTP過期標題正在崩潰我的網站。我究竟做錯了什麼?
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /home/mydirectory
<Directory /home/mydirectory/>
ExpiresActive On
ExpiresByType text/html "access plus 1 months"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType image/jpg "access plus 1 months"
ExpiresByType image/jpeg "access plus 1 months"
ExpiresByType image/png "access plus 1 months"
ExpiresByType image/vnd.microsoft.icon "access plus 1 months"
ExpiresByType image/x-icon "access plus 1 months"
ExpiresByType image/ico "access plus 1 months"
ExpiresByType application/javascript .now plus 1 months.
ExpiresByType application/x-javascript .now plus 1 months.
ExpiresByType text/javascript .now plus 1 months.
ExpiresByType text/css .now plus 1 months.
ExpiresDefault "access plus 1 days
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
我都試過了以下配置我的httpd.conf文件:
LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
ExpiresActive On
ExpiresDefault "access plus 7 days"
<Directory "/home/mydirectory">
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
ExpiresByType text/html "access plus 1 day"
ExpiresByType text/css "access plus 1 day"
ExpiresByType text/javascript "access plus 1 day"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 day"
</Directory>
和
LoadModule expires_module /usr/lib/apache2/modules/mod_expires.so
我不能配置爲工作的任何組合我。我檢查過,mod_expires.so位於正確的位置。我哪裏錯了?
我已將文檔根從/var/www
更改爲/home/mydirectory
。在我嘗試修改HTTP標頭之前,這沒有造成任何問題,因此我認爲它與該問題沒有任何關係。
什麼是「崩潰您的網站」?日誌告訴你什麼? – CodeCaster 2013-07-02 12:19:40
你確定是第19行嗎?這更像22日。 – 2015-08-26 22:11:33