I am using excellent https://github.com/liip/LiipImagineBundle bundle for showing images. But when working in dev enviroment, generated urls become something like:

<img src="/app_dev.php/media/cache/60x60/somefile.jpg">

and when there are 20-30 images, my programs crawls. I also get lots of connection timeouts because app_dev.php goes thru entire FW.

Question: Can I somehow set Symfony to generate production URL for some parts, while still in dev? Ie. that LiipImagineBundle always generate production URL, no matter what enviroment is?

Or how can I change .htaccess to use

/media/cache/60x60/file.jpg

whenever there is

app_dev.php/media/cache/* 

found

有帮助吗?

解决方案

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^app_dev\.php(/media/cache/.*)$ $1 [L,R=301,NC]

Reference: Apache mod_rewrite Introduction

其他提示

You can try adding (preferably before any other rules but after any redirect rules) this in the htaccess file in your document root:

RewriteEngine On
RewriteRule ^app_dev\.php/media/cache/(.*)$ /media/cache/$1 [L]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top