How to set Php's auto_prepend_file directive per directory?
Use .user.ini files.
http://php.net/manual/en/configuration.file.per-user.php
How can I specify an auto_prepend_file in my .htaccess file without hardcoding the absolute path?
Short answer, no.
Longs answer, you can probably make it work like you want to.
You could create the auto prepend file to use the $_SERVER['DOCUMENT_ROOT']
var to determine which file to include using a switch/if-else constructin.
Or you could use the __FILE__
var in combination with realpath
to include/require the "prepend" file you want.
auto-prepend.phprequire_once(realpath(__FILE__) . '/prepend.php');
//edit:
thought of it some more, __FILE__
will probably refer to the prepend file in stead of the requested file, so it might not work as expected.
Using auto_prepend_file into .user.ini file in PHP
Well, the manual says it all:
Since PHP 5.3.0, PHP includes support for configuration INI files on a
per-directory basis. These files are processed only by the CGI/FastCGI
SAPI. This functionality obsoletes the PECL htscanner extension.
And:
If you are using Apache, use .htaccess files for the same effect.
... though it actually refers to the Apache module (mod_php
).
If you need SAPI-independent custom settings I'm afraid you'll have to use both. You can minimise the maintenance burden if you keep those settings to the minimum (most PHP directives can be provided in PHP code itself). And you need to ensure that .htaccess
settings don't crash when mod_php
is not available:
<IfModule mod_php5.c>
php_value auto_prepend_file /Volumes/www/project_name/admin/libs/variables.php
</IfModule>
How to config apache virtual host to let every php script include one or more common php script?
Depending on your server config you should be able to use auto_prepend_file in your .htaccess file:
php_value auto_prepend_file "config.php"
Or, for Virtual Host:
<VirtualHost *:80>
php_value auto_prepend_file "config.php"
</VirtualHost>
How to verify logins on direct navigation to resource pages on an AJAX site
Setting the CHMOD settings of my resource folders to 0750 appear to be allowing the AJAX commands to execute without allowing direct access to the files. If anyone knows of any other security caveats to be aware of when doing this let me know. Thanks.
Related Topics
Need to Merge Multiple PDF's into a Single PDF with Table of Contents Sections
Using PHP, How to Insert Text Without Overwriting to the Beginning of a Text File
Nl2Br() Equivalent in JavaScript
How to Remove a Password from a PDF File Using PHP
Problems with Secure Bind to Active Directory Using PHP
Understanding PHP "Out of Memory" Error
How to Get the Total Found Rows Without Considering the Limit in Pdo
Mysql: Get Total in Last Row of MySQL Result
PHP Thumbnail Image Resizing with Proportions
Firefox Error 'No Element Found'
PHP Type Hinting Not Getting Along with Interfaces and Abstract Classes
Validate That Input String Does Not Exceed Word Limit