自适应图像CakePHP的htaccess的 [英] Adaptive images CakePHP htaccess

查看:177
本文介绍了自适应图像CakePHP的htaccess的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让马特·威尔考克斯自适应图像与CakePHP的工作,但没有成功。 http://adaptive-images.com/

CakePHP附带它自己的三个.htaccess文件。在 / ,一个在 /应用/ ,一个在 /应用程序/ Web根目录/

我需要得到这四个文件以这样一种方式,图像的请求被发送到文件自适应images.php,我已经把在根一起工作。

这是从自适应图像htaccess的

 < IfModule mod_rewrite.c>
    选项​​+的FollowSymLinks
    RewriteEngine叙述上

    #自适应,图片---------------------------------------------- -------------------------------------

    #添加您希望从自适应,图像处理省略在新行的任何目录,如下所示:
    #的RewriteCond%{REQUEST_URI}!一些目录
    #的RewriteCond%{REQUEST_URI}!另一个目录

    的RewriteCond%{REQUEST_URI}!资产

    #发送任何GIF,JPG或PNG请求未存储内的上述目录之一
    #以自适应images.php,所以我们可以选择适当大小的版本
    重写规则\(?: JPE G |?GIF | PNG)。$自适应images.php

    #END自适应,图像--------------------------------------------- ----------------------------------
< / IfModule>
 

这是根/

蛋糕的htaccess

 < IfModule mod_rewrite.c>
   RewriteEngine叙述上
   重写规则^ $应用程序/ Web根目录/ [L]
   重写规则(。*)的应用程序/ Web根目录/ $ 1 [L]
< / IfModule>
 

这是从/应用程序/

蛋糕的htaccess

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    重写规则^ $ Webroot公司/ [L]
    重写规则(。*)根目录/ $ 1 [L]
< / IfModule>
 

这是从/应用程序/ Web根目录

蛋糕的htaccess

 < IfModule mod_rewrite.c>
    RewriteEngine叙述上
    的RewriteCond%{} REQUEST_FILENAME!-d
    的RewriteCond%{} REQUEST_FILENAME!-f
    重写规则^(。*)$的index.php [QSA,L]
< / IfModule>
 

我想从自适应图像的规则首先要进来的文件之一,并有可能对最后一条规则什么的添加[L]。但唯一的事情我已经成功完成迄今为止被打破路径图像 /img/myimage.gif 使蛋糕开始寻找一个ImgController代替。

在Apache日志并没有给我任何有价值的东西。

有什么建议?

编辑:目前看起来像这样

我的修改 / - htaccess的,现在看起来像下面。蛋糕给我一个错误关于丢失ImgController没有图像在自适应图像应该把它们放在AI-缓存文件夹中创建。

 < IfModule mod_rewrite.c>
   选项​​+的FollowSymLinks
   RewriteEngine叙述上

    的RewriteCond%{REQUEST_URI}!资产
    重写规则\(?: JPE G |?GIF | PNG)。$自适应images.php

   的RewriteCond%{REQUEST_URI}!自适应影像\ .PHP [NC]
   重写规则^ $应用程序/ Web根目录/ [L]
   重写规则(。*)的应用程序/ Web根目录/ $ 1 [L]
< / IfModule>
 

解决方案

好吧,我得到它的工作,即使它也许不是最优化的解决方案是有的。

我只是改变了 /应用程序/ Web根目录 -folder像htaccess的下方

 < IfModule mod_rewrite.c>
    选项​​+的FollowSymLinks
    RewriteEngine叙述上

    的RewriteCond%{REQUEST_URI}!debug_kit
    重写规则\(?: JPE G |?GIF | PNG)。$自适应images.php [L]

    的RewriteCond%{} REQUEST_FILENAME!-d
    的RewriteCond%{} REQUEST_FILENAME!-f
    重写规则^(。*)$的index.php [QSA,L]
< / IfModule>
 

和增加了​​自适应images.php文件应用程序/ Web根目录这或许会是更好有在供应商目录,但至少自适应images.php文件它的工作原理。

我做出适应性images.php两个转变

  $ cache_path =应用程序的/ tmp /缓存/ AI-缓存;
$ SOURCE_FILE = $ DOCUMENT_ROOT'/程序/ webroot的$ requested_uri。;
 

I'm trying to get Matt Wilcox adaptive images to work with CakePHP without success. http://adaptive-images.com/

CakePHP comes with three .htaccess files of it's own. In in /, one in /app/ and one in /app/webroot/

I need to get these four files to work together in such a way that image-requests are sent to the file adaptive-images.php that I've put in the root.

This is the htaccess from adaptive-images

<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} !some-directory
    # RewriteCond %{REQUEST_URI} !another-directory

    RewriteCond %{REQUEST_URI} !assets

    # 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>

This is cakes htaccess from root /

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

This is cakes htaccess from /app/

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
</IfModule>

This is cakes htaccess from /app/webroot

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

I assume the rules from adaptive images has to come first in one of the files and potentially add an [L] for last rule or something. But the only thing I've managed to accomplish so far is breaking the paths to images /img/myimage.gifso that Cake starts to look for an ImgController instead.

The Apache logs doesn't give me anything of value.

Any suggestions?

Edit: Currently looks like this

My modified / - htaccess now looks like below. Cake gives me an error about a missing ImgController and no images are created in the ai-cache-folder that adaptive images is supposed to put them in.

<IfModule mod_rewrite.c>
   Options +FollowSymlinks
   RewriteEngine on

    RewriteCond %{REQUEST_URI} !assets
    RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php

   RewriteCond %{REQUEST_URI} !adaptive-images\.php [NC]
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

解决方案

Alright I got it working even if it's perhaps not the most optimal solution there is.

I only changed the htaccess in the /app/webroot-folder like below

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !debug_kit
    RewriteRule \.(?:jpe?g|gif|png)$ adaptive-images.php [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

and added the adaptive-images.php file to app/webroot It would perhaps be nicer to have the adaptive-images.php file in the Vendor directory but at least it works.

I made two changes in adaptive-images.php

$cache_path    = "app/tmp/cache/ai-cache";
$source_file    = $document_root.'/app/webroot'.$requested_uri;

这篇关于自适应图像CakePHP的htaccess的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆