V
V
Valery Selitsky2012-11-27 15:39:27
PHP
Valery Selitsky, 2012-11-27 15:39:27

Apache Mod_Rewrite - how to force stop after RewriteRule fire?

I have:
.htaccess:

RewriteEngine On

RewriteRule ^/image/.+$ imageWrapper.php [L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
— standard from distribution of Zend Framework 1+ plus my rule for /image/;
Apache 2.2.22;
Expectation:
When accessing the URL http://localhost/image/w/150/h/150/sertificate.jpg, the imageWrapper.php script is executed, into which REQUEST_URI /image/w/150/h/150/sertificate.jpg is passed, after which the script successfully completes and dies.
Reality:
The last rule is executed, the Zend application is launched, the Router reports a non-existent controller and action.
Question:
How to write my design so that the expectation comes true , and why does it turn out to be reality ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valery Selitsky, 2012-11-27
@WaveCut

He asked, he answered. You must use the condition:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/image\/.*$
RewriteRule  ^.*$ imageWrapper.php [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

A
AlexPres, 2013-06-04
@AlexPres

If you have a loaded application and Nginx works before Apache, then it is better to transfer these rules there. Otherwise it turns out Nginx → Apache → .htaccess
I tried to do this, for redirects it turns out several times faster, but you need to know what to write in Nginx, and even without IFs (because they are evil )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question