重写.htaccess文件的脚本适用于wamp但不适用于网络上的共享主机

I have written a CMS that allows for control of the .htaccess file through administration. Everything is fine on my wamp on my computer and the updates occur and the .htaccess is rewritten as designed. However, on the a shared host on the net the script returns the update/rewrite page as a blank page with no source.

Viewing through the js console in chrome it flashes the following error which I was able to catch in print screen:

error

Though the update page is returned blank and the 500 error flashes the site itself is not affected and renders although an internal error has occurred.

My question... Is there perhaps a setting in php.ini or somewhere else on the server that I am not aware of that would prevent the .htaccess file from being dynamically updated?

My wamp is running PHP 5.5.12 while the server is 5.4

=== QUESTION UPDATE ===

The server is no recognizing and as a result the .htaccess file is rendering in a single line without link breaks and is commenting itself out.

Here is the original code:

# Prevent viewing of .htaccess file
    if($view_htaccess == 1){
    $htaccess_code .= "# Prevent viewing of .htaccess file ";
    $htaccess_code .= "<Files .htaccess> ";
    $htaccess_code .= "order allow,deny ";
    $htaccess_code .= "deny from all ";
    $htaccess_code .= "</Files> ";
    $htaccess_code .= " ";
    }

I tried and as well... not sure where to go from here

Thanks for any assistance in advance,

Pete

ISSUE RESOLVED:

In wamp on my computer the server was not but did recognize so I programmed accordingly. Upon uploading to the server a 500 Error was caused by the server not recognizing or and running the code together where it was commenting itself out.

Although I do not why it worked the solution I found was to save the generated htaccess code to a temporary text file fist then call the contents of the temp text file through file_get_contents('htaccess-temp.txt'); and then save it to the htaccess file.

This however resulted in another issue where the script automatically was adding slashes to the slashes in the robot user agents Internet\ Ninja which required a str_replace("\\", "\\", $get_htaccess_code); to be applied to the return of file_get_contents('htaccess-temp.txt'); before saving to the htaccess file. The slash to replace with needed to be escaped.

The final code:

$file_handle = fopen('htaccess-temp.txt', 'w'); 
fwrite($file_handle, $htaccess_code); fclose($file_handle); 
$get_htaccess_code = file_get_contents('htaccess-temp.txt');    
$get_htaccess_code = str_replace("\\", "\\", $get_htaccess_code);
$file_handle = fopen($level.'.htaccess', 'w'); 
fwrite($file_handle, $get_htaccess_code); fclose($file_handle);

Though this works I still do not understand why I had to save the code to text first... and why slashes were being added. If you have any idea please comment.

Pete