2013-03-19 71 views
0

我想在本地wamp服務器上使用adaptive images。 ai-cache文件夾沒有顯示,圖像也沒有被替換。根據this thread,我在.htaccess文件中嘗試了RewriteRule .(?:jpe?g|gif|png)$ test.jpg,並在相同的文件夾中添加了test.jpg,但這不會改變任何內容。WAMP mod_rewrite重寫規則不起作用

在WAMP菜單Apache->的Apache模塊 - > rewrite_module檢查,它是在httpd.conf LoadModule rewrite_module modules/mod_rewrite.so

我重新啓動所有服務WAMP每當我改變的.htaccess註釋。另外,如果我在頂部寫入asdf,它確實會給出500內部服務器錯誤,所以我知道該文件正在被讀取。

我在做什麼錯?

這裏是(WWW /演示/測試/)位於幾個子目錄的.htaccess文件:

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 

    # Adaptive-Images ----------------------------------------------------------------------------------- 

    # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows: 
    # RewriteCond %{REQUEST_URI} !ignore-this-directory 
    # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too 

    RewriteCond %{REQUEST_URI} !assets 

    # don't apply the AI behaviour to images inside AI's cache folder: 
    RewriteCond %{REQUEST_URI} !ai-cache 

    # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories 
    # to adaptive-images.php so we can select appropriately sized versions 

    RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php 

    # END Adaptive-Images ------------------------------------------------------------------------------- 
</IfModule> 

這裏是我的httpd.conf部分:

# 
# This should be changed to whatever you set DocumentRoot to. 
# 
<Directory "c:/wamp/www/"> 
    # 
    # Possible values for the Options directive are "None", "All", 
    # or any combination of: 
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All" 
    # doesn't give it to you. 
    # 
    # The Options directive is both complicated and important. Please see 
    # http://httpd.apache.org/docs/2.2/mod/core.html#options 
    # for more information. 
    # 
    Options None 

    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # Options FileInfo AuthConfig Limit 
    # 
    AllowOverride all 

    # 
    # Controls who can get stuff from this server. 
    # 

# onlineoffline tag - don't remove 
    Order Deny,Allow 
    Deny from all 
    Allow from 127.0.0.1 
    Allow from ::1: 

</Directory> 
+0

有解決[這裏]類似的問題(http://stackoverflow.com/questions/15105877/adaptive-images-cakephp -htaccess)。 – 2013-03-19 03:58:46

回答

1

好吧,我找出它不工作的原因!這根本不是WAMP/localhost問題。

由於某些原因,自適應圖像附帶的默認.htacess文件不適用於任何情況。但是......所有我必須添加的是[NC,L]到重寫規則的末尾。 html和image標籤的.jpg擴展名爲小寫,但是我的圖像文件是用大寫字母(.JPG)編寫的,直到我在文件瀏覽器中打開文件擴展名時才注意到。

  • nocase | NC:使模式比較不區分大小寫。
  • last | L:立即停止重寫過程,並且不要應用任何 更多規則。特別注意每個目錄的注意事項和.htaccess 上下文(另請參閱END標誌)。

Source

下面是最終代碼:

<IfModule mod_rewrite.c> 
    Options +FollowSymlinks 
    RewriteEngine On 

    # Adaptive-Images ----------------------------------------------------------------------------------- 

    # Add any directories you wish to omit from the Adaptive-Images process on a new line, as follows: 
    # RewriteCond %{REQUEST_URI} !ignore-this-directory 
    # RewriteCond %{REQUEST_URI} !and-ignore-this-directory-too 

    RewriteCond %{REQUEST_URI} !assets 

    # don't apply the AI behaviour to images inside AI's cache folder: 
    RewriteCond %{REQUEST_URI} !ai-cache 

    # Send any GIF, JPG, or PNG request that IS NOT stored inside one of the above directories 
    # to adaptive-images.php so we can select appropriately sized versions 

    RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php [NC,L] 

    # END Adaptive-Images ------------------------------------------------------------------------------- 
</IfModule>