1

I have a php application, which requires an .htaccess file with this rewriterule in it:

RewriteRule .* blog_manager/controller/frontController.php

I've opened a new hosting account and I wanted them to disable the extension: suhosin.mt_srand.ignore

for that they added the following lines to the .htaccess file, which are supposed to load a custom .ini file that disables that extension:

AddHandler phpini-cgi .php
Action phpini-cgi /cgi-bin/php5-custom-ini.cgi

but then, I started getting 500 Internal server error... apparently, the rewriterule and the lines they added don't work together.

I've tried to disable that extension with ini_set() in the code and with php_flag/php_value in the htaccess file, but both failed.

does anybody know why is that? Is there anything that can be done to allow the rewriterule and still disable that extension?

anubhava
  • 761,203
  • 64
  • 569
  • 643
Alon Dor
  • 111
  • 10
  • check your Apache error.log – anubhava Jan 27 '14 at 16:42
  • this is the error in the log: Request exceeded the limit of 20 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. – Alon Dor Jan 28 '14 at 07:52

1 Answers1

1

Change your rule to this:

RewriteCond %{REQUEST_URI} !/blog_manager/controller/frontController.php [NC]
RewriteRule ^ blog_manager/controller/frontController.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • It worked, even only with: `RewriteCond %{REQUEST_FILENAME} !-f` but this way, I am exposing my files to view by anyone... is that the only way? – Alon Dor Jan 28 '14 at 08:31
  • ok see updated code, it will forward everything to controller.php now. – anubhava Jan 28 '14 at 08:43
  • Yes, but now I get the redirects again, because of the 'AddHandler' lines – Alon Dor Jan 28 '14 at 09:05
  • It works! can you explain to me what was the problem, and how does it solve it? – Alon Dor Jan 28 '14 at 09:33
  • I just removed `^` (start of line anchor) from `RewriteCond` as I think your rule is not directly placed in `DocumentRoot`. – anubhava Jan 28 '14 at 09:37
  • Ok, but can you explain why adding the condition and changing the rule solved the problem? why was it redirecting in a loop in the first place? – Alon Dor Jan 28 '14 at 10:48
  • If `RewriteCond` is taken out and `mod_rewrite` will try to rewrite every URI to `/blog_manager/controller/frontController.php` and remember `mod_rewrite` rules are applied again & again as long as there is a matching condition. `RewriteCond` above stops application of rules in 2nd pass and at that point rewrite engine bails out. – anubhava Jan 28 '14 at 10:50
  • But it worked fine before adding the `AddHandler` & `Action` lines, for some reason after adding those lines (which are suppose to load a custom php.ini file) the redirect problem started, can you think of a reason why? and how adding the condition solved it? – Alon Dor Jan 28 '14 at 10:55
  • Yes it was caused by `Action phpini-cgi /cgi-bin/php5-custom-ini.cgi ` line which forwards every file.php request to `/cgi-bin/php5-custom-ini.cgi/file.php` And then rewrite rule takes everything to `/blog_manager/controller/frontController.php` they both keep taking turns and Apache runs out of RecursionLimit. Having `RewriteCond` stops execution of this rewrite rule 2nd time and prevents looping. – anubhava Jan 28 '14 at 11:10