Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^myurl.com [NC] 
RewriteRule ^(.*)$ http://www.myurl.com/$1 [L,R=301] 


Header set X-UA-Compatible "IE=EmulateIE8" 
# PHP error handling for production servers

# disable display of startup errors
php_flag display_startup_errors off

# disable display of all other errors
php_flag display_errors off

# disable html markup of errors
php_flag html_errors off

# enable logging of errors
php_flag log_errors on

# disable ignoring of repeat errors
php_flag ignore_repeated_errors off

# disable ignoring of unique source errors
php_flag ignore_repeated_source off

# enable logging of php memory leaks
php_flag report_memleaks on

# preserve most recent error via php_errormsg
php_flag track_errors on

# disable formatting of error reference links
php_value docref_root 0

# disable formatting of error reference links
php_value docref_ext 0

# specify path to php error log
php_value error_log /public_html/safe/PHP_errors.log

# specify recording of all php errors
php_value error_reporting 999999999

# disable max error string length
php_value log_errors_max_len 0

# protect error log by preventing public access
<Files /public_html/safe/PHP_errors.log>
 Order allow,deny
 Deny from all
 Satisfy All
</Files>
ErrorDocument 404 /404.php
ErrorDocument 400 /400.php
ErrorDocument 401 /401.php
ErrorDocument 403 /403.php
ErrorDocument 500 /500.php
Options -Indexes

That's my code, the funny thing is i copied this from a website i designed and it worked on their, but it won't work on a new website i am designing.
Any help will do

Dani AI

Generated

A quick diagnostic and practical fixes for (and confirmation of ’s point).

The 500 after adding PHP directives in .htaccess almost always means Apache rejected one of those directives. That happens when the server runs PHP as CGI/FastCGI (suPHP, PHP‑FPM, etc.) instead of as an Apache module — in that case php_flag/php_value are invalid and produce a 500. A simple way to prove this is to isolate the .htaccess and inspect PHP’s SAPI.

Create a tiny phpinfo file and open it in a browser; check the “Server API” and “Loaded Configuration File” entries:

<?php
phpinfo();
?>

If Server API is “FPM/FastCGI” or “CGI/FastCGI”, switch strategies. As a quick test, rename the .htaccess (for example to .htaccess.bak) — if the 500 disappears the file contains the offending directive. Also check the site’s Apache error log (it will usually show the exact complaint such as “Invalid command 'php_flag' ...”).

Workarounds and fixes:

  • If PHP runs as CGI/suPHP: place a local php.ini in the account root (or use the host’s per-site php.ini facility). Example entries (example only — adjust paths/values to the server):
; local php.ini
display_errors = Off
log_errors = On
error_log = /home/username/logs/php_errors.log
error_reporting = E_ALL
  • If PHP runs under PHP‑FPM: use .user.ini in the document root or set per‑pool settings in the FPM config.
  • As an application-level fallback, call ini_set() and error_reporting() at the start of the app.

Other gotchas: the error_log path must be an absolute server path and writable by PHP; protect log files with Apache 2.4 syntax (older Order allow,deny is deprecated). Example protection:

<Files "php_errors.log">
  Require all denied
</Files>

If none of the above is allowed, contact the host and provide the Apache error log lines — they’ll indicate which directive caused the 500.

If that new website is on a new server the hosting company probably have a different server config...are they using phpexec?

If they are you won't be able to change PHP settings from .htaccess.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.