2012-02-06 56 views
0

我使用的1and1,我按照本指南,以便儘可能多的我的網站的壓縮,我可以:htaccess,如何使用gzip壓縮+隱藏.html擴展名?

http://mrrena.blogspot.com/2009/01/how-to-compress-php-and-other-text.html?showComment=1328550165472#c3296286447260746640

我以前也用我的htaccess文件來隱藏HTML擴展的每個網頁。現在我已經應用了新的代碼來通過路由它來壓縮一切,我不再隱藏html擴展,並且我的許多web鏈接都被破壞了。這是我的htaccess文件的複製粘貼。

Header unset Pragma 
FileETag None 
Header unset ETag 

# cache images/pdf docs for 10 days 
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif|css)$"> 
    Header set Cache-Control "max-age=864000, public, must-revalidate" 
    Header unset Last-Modified 
</FilesMatch> 

# cache html/htm/xml/txt diles for 2 days 
<FilesMatch "\.(html|htm|xml|txt|xsl)$"> 
    Header set Cache-Control "max-age=7200, must-revalidate" 
</FilesMatch> 

# tells the server to process all the file extensions specified through PHP5 for compression purposes 
RemoveHandler .css 
AddType x-mapp-php5 .php .shtml .html .htm .txt .js .css .ttf .svg .woff 

# 
Options +FollowSymLinks 
RewriteEngine On 
# 
# REDIRECT /folder/index.html to /folder/ 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/ 
RewriteRule ^(([^/]+/)*)index\.html$ http://weaverinnovations.com/$1 [R=301,L] 
# 

這樣的事情遠遠超出了我的專業領域,以及任何幫助,以及如何避開衝突的解釋將不勝感激。

謝謝!

+0

也許是一個明顯的問題,但是您是否在重新啓動瀏覽器之間對.html擴展名進行.htaccess更改?使用301重定向您的瀏覽器將「記住」這些,直到您重新啓動....由於忽略了這個事實而導致了一個以上的頭痛。 – 2012-02-06 23:14:18

回答

0

性能

這樣的事情遠遠超出了我的專業領域,...

在這種情況下

嗯,我希望「保持簡單愚蠢」。我可能對此有更多的瞭解。使用PHP作爲靜態文件的包裝,每個文件訪問添加〜100毫秒和而不是是一個好主意。

如果您想對如何調整你的應用程序的響應看看我的博客標籤,WebfusionPerformance,這給了這個託管服務提供商一些非常具體的調整建議提出了一些建議。我的博客運行在相同的託管基礎​​架構上(Webfusion只是同一家公司的另一個品牌名稱)您會看到我的Google Pagespeed得分爲99/100,與Google主頁達到的一樣好,所以我懷疑你這會改進。 (你的目前是56/100)。我現在的規則是:

AddType image/x-icon .ico 
ExpiresActive On 
ExpiresByType text/css  "access plus 1 month" 
ExpiresByType text/javascript "access plus 1 month" 
ExpiresByType image/x-icon "access plus 1 month" 
ExpiresByType image/jpeg  "access plus 1 week" 
ExpiresByType image/gif  "access plus 1 week" 
ExpiresByType image/png  "access plus 1 week" 

<Files "sitemap.*"> 
    ForceType text/xml 
</Files> 

<Files "rss*"> 
    ForceType text/xml 
</Files> 

AddOutputFilter DEFLATE js css 
AddOutputFilterByType DEFLATE text/html text/plain test/css text/xml application/xml 

<FilesMatch "\.(css|js|gif|jpe?g|png|pdf)$"> 
    Header add "Cache-Control" "public, max-age=604800" 
</FilesMatch> 

<FilesMatch "\.(js|css|xml|html)$"> 
    Header append Vary Accept-Encoding 
</FilesMatch> 

使用「必須重新驗證」指令是不明智的,如果你有一個靜態文件PHP包裝,尤其是在一個共享的託管服務,因爲你還需要支付PHP圖像啓動處罰和您需要處理If-Modified-SinceIf-None-Match請求標頭並正確發出304響應。

HTML鏈接打破

如果你問每個問題一個問題,而不是兩個它確實有幫助。你能否詳細描述一下,在給出一些特定的前後例子的情況下,究竟什麼樣的鏈接「破碎」,然後我們可以給出具體的迴應。