Search code examples
php.htaccesssymfonyliipimaginebundle

Use prod enviroment on some urls, while in dev env


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


Solution

  • 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