Reputation: 3011
I have configured .htaccess
file to append PHP
errors into a log file by:
php_flag log_errors on
php_value error_log /home/user_id/public_html/PHP_errors.php
php_value error_reporting 6143
and It works fine in the remote server(linux). But the above path does not exist in the local server(windows). I tried:
php_value error_log ./PHP_errors.php
And it works in local, But it does not work in the remote server.
Is it possible to restrict the above directions to the remote server? Something like:
Condition %{http_host} ^example.com$
php_value error_log /home/user_id/public_html/PHP_errors.php
Condition %{http_host} ^localhost$
php_value error_log ./PHP_errors.php
(I have not access to php.ini file in the remote server but of course I can change it in the local)
Upvotes: 2
Views: 894
Reputation: 786091
Using Apache 2.4 you can use this conditional snippet:
<If "%{HTTP_HOST} =~ m#^(www\.)?example\.com$#">
php_value error_log /home/user_id/public_html/PHP_errors.php
</If>
<If "%{HTTP_HOST} =~ m#localhost#">
php_value error_log ./PHP_errors.php
</If>
Upvotes: 4
Reputation: 462
There's a similar question with a good answer here: https://stackoverflow.com/a/4139899/5550193
Additionally, you may not want to give your log file the extension .php
as it opens up for some potential exploits. Better call it .log
or something else that doesn't have potential to be sent to an interpreter by Apache.
Upvotes: 0
Reputation: 818
You can control this from PHP. So you can have a configuration file in PHP that is included on the start of application and sets error_log() and error_reporting().
Then you can either have several versions of this file based on your environment (local or remote) or you can check for $_SERVER variable to set up correct paths.
Upvotes: 0