04-15-2017, 02:11 AM
I have a resize controller with method named index which performs the resizing.
I want to rewrite requests for images which don't exist to this function, but can't seem to get it to work.
I really have no experience in writing such rules, any help would be appreciated.
Edit:
I was running it from folder CIAppScaffolding, so I needed to add RewriteBase /CIAppScaffolding/
Edit: It worked, but for some reason, seems to have stopped working. I'm confused.
Edit: I think it didn't work, I must've hit the URL of a previously generated image. So back to the original question.
PHP Code:
public function index($location = '', $size = '', $image = '') {
//Some code here
}
I want to rewrite requests for images which don't exist to this function, but can't seem to get it to work.
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^public/upload/([a-z]+)/(large|catalog|thumb)/([^/]+\.(?:jpg|png|jpeg))$ index.php/resize/index/$1/$2/$3 [L]
RewriteCond $1 !^(index\.php|public|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
I really have no experience in writing such rules, any help would be appreciated.
Edit:
I was running it from folder CIAppScaffolding, so I needed to add RewriteBase /CIAppScaffolding/
Edit: It worked, but for some reason, seems to have stopped working. I'm confused.
Edit: I think it didn't work, I must've hit the URL of a previously generated image. So back to the original question.