I want to set a php_value flag only for a specific url (rewrited) path. I'm using htaccess to accomplish this. The framework I'm using is CodeIgniter, so there is one htaccess file and url routes are handled by php.
Only the backend of the website should have php_value max_input_vars 3000. The url is http://www.example.com/admin/dashboard
I was thinking about this in htaccess file:
<Location /website.com/admin>
php_value max_input_vars 20000
</Location>
Okay since you cannot upgrade your Apache to latest versions here is one work-around way to get this conditional setting in place.
1 - In the DOCUMENT_ROOT Run this command to create a symbolic link of index.php as __anything.php
ln -s index.php __anything.php
2 - Put the new code in DOCUMENT_ROOT/.htaccess just below RewriteEngine On line. You overall .htaccess would look like this:
# forward all URLs starting with /admin/ to __anything.php
RewriteRule ^(admin(?:/.*|))$ __anything.php?/$1 [L,NC]
# set max_input_vars to 2000 for file __anything.php
<FilesMatch "^__anything\.php">
php_value max_input_vars 20000
</FilesMatch>
# your regular Codeignitor controller code
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
PS: I don't have CI installed so I cannot really test this with CI but otherwise I tested this and got enhanced max_input_vars value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With