All posts by Rajmahendran P

HTTP to HTTPS Htaccess redirection for particular URL

We could use the below htaccess code to redirect particular URL from HTTP to HTTPS. 

I the below code, we have added redirection for “donate_wwp.php” payment page from HTTP to HTTPS.

 

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} donate_wwp.php
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

 

NOTE: I have added it top of the htaccess file.

 

Hacked site malware cleaning steps and Securing steps

Please follow the below steps to clean the Hacked and malware code.

  1. Backup full database and files.
  2. Change FTP(cpanel) and database password.
    NOTE: Once updated the database password, we need to update new password information in config file. For wordpress, wp-config.php is config file. This file located in wordpress root folder.  It will change based on CMS and framework which one you have used. Please find below image to update wp-config.php file.
     
  3. Scan full site using online tool and security plugins.
    We could use Wordfence for wordpress and Scan full site using your local antivirus software with download backup files. Please find the below image to scan the full site using Wordfence.
    config_file_change_password

Online Scan Sites:
https://sitecheck.sucuri.net/
https://www.stopbadware.org/request-review
http://evuln.com/tools/malware-scanner/ 

4. Search and clean malware code in server files.
       Remove all malware code which is you found using Step 3 scan steps.
       Also, you could recheck the below files and remove any malware code if exist. You could found malware code very easy. Because, Surely malware code different from default function and code.  
           1. Index.php files in wordpress root folder and theme.
           2. Header.php, footer.php and template files within all Themes which exist in /wp-content/themes/
           3. config.php and htaccess file in root folder.

5. Search and clean within database.
     Search the code within database using phpMyAdmin or other interface. Search keyword, you could take some part of malware code from scanned result. Remove it from database tables,if you found.  

6. Now, surely your site back to live.

7. Also, ask you server support team to scan the full site and do the action based on support team scan result.

8. Finally need to do the below points to make sure to avoid hacking again! Please check other post in below link.

Update your wordpress site security settings

504 Gateway Time-out issue

In some server, while we doing the long execution, pages will redirect to “504 Gateway Time-out issue“.

Its due to execution time out issue.
It will 504 issue in below cases.
1. Importing SQL from server phpMyAdmin
2. Working on uploading image process.
3. Uploading large file.
4. Any process runes more then “max_execution_time

Solution:
The max_execution_time default set to 6000 seconds and the max_input time is set to 60 seconds. I would recommend
setting these higher.

We could update in below path in Plesk:
Home->Domains->domainname.com->PHP Settings->max_execution_time
Home->Domains->domainname.com->PHP Settings->max_input_time

Also, we could change max_execution_time and max_input_time through htaccess, php.ini OR PHP too.

 

Also, Some times we need to update max_children(Plesk) server.

To increase this setting, simply enter the below in the PHP settings tab > Additional configuration directives, where
X is the number you would like to increase this to. Please be aware however, that raising this too high may lead too
memory usage issues. However for the moment there is plenty of RAM available.

pm.max_children = X

 

Need to take action in below points once removed the malware code

You will want to take all of the following actions for each account/CMS to get this resolved:


-Examine the indicated files and if necessary, remove the identified files from public_html.
-Update the core CMS installation and all themes, plugins, addons, modules, templates, etc.
-Change the cPanel account password and any FTP account passwords that have access to upload.
-Change the CMS administrator password.
-Change any email account passwords with access to resetting the CMS administrator password.
-Scan any computers with access to the server with anti-virus software and Malwarebytes and Spybot Search&Destroy.

Going forward, you’ll want to make sure that you keep the CMS installations more up-to-date and please let me know if you have any questions.

SMTP mail Configuration

Please follow the below steps to configure the SMTP mailing process within your server.

  1. Click Here to Download Recent phpmailer files.
  2. Create php file with below coding.
  3. Include PHPMailer Autoload file as like below coding. (This file will change based on phpmailer  version)
    <?php
    require_once("SMTP_NEW/PHPMailerAutoload.php"); // path to the PHPMailer class
    ?>
  4.  Use the below code to implement the Mailing process.
    <?php
    $mail = new PHPMailer;//$mail->SMTPDebug = 3; // Enable verbose debug output
    $mail->isSMTP(); // Set mailer to use SMTP
    $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
    $mail->SMTPAuth = true; // Enable SMTP authentication
    $mail->Username = 'user@example.com'; // SMTP username
    $mail->Password = 'secret'; // SMTP password
    $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587; // TCP port to connect to
    $mail->setFrom('from@example.com', 'Mailer');
    $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
    $mail->addAddress('ellen@example.com'); // Name is optional
    $mail->addReplyTo('info@example.com', 'Information');
    $mail->addCC('cc@example.com');
    $mail->addBCC('bcc@example.com');
    $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
    $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
    $mail->isHTML(true); // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
    echo 'Message has been sent';
    }
    ?>
  5.  Follow the below STEPS to Fix the issue.While we configure it, we have tried with GMAIL SMTP as like below configuration:
    <?php
    $mail->Mailer = "smtp";
    $mail->SMTPAuth = true; // turn on SMTP authentication
    $mail->SMTPSecure = "ssl"; // OR $mail->SMTPSecure = 'tls';
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 465;
    ?>
  6.  But, above settings displayed SMTP connection error. Then, we have tried using Port 587Then, enabled the Debug process using 
    <?php
    $mail->SMTPDebug = 1;
    ?>

     
  7.  No help, then we have discussed with server support team to confirm the OPEN PORT and SMTP Configuration details.
  8. Finally we have followed below URLs steps to fix the issue. Its related to Google URLs. Its related the enable all access permission to Google SMTP.
    https://accounts.google.com/b/0/DisplayUnlockCaptcha
    https://support.google.com/mail/answer/14257?rd=1

    Allowing less secure apps to access your account:
    https://support.google.com/accounts/answer/6010255
    https://www.google.com/settings/security/lesssecureapps (Access for less secure apps — Turn on)

Need to know below information:
1. While we configure the Gmail SMTP, it not allow to send mail “From ” another email. Like if you configured the SMTP using “xxxx@gmail.com“, sending mail default from address will be same “xxxx@gmail.com“.

If we need to change as client email, we need to create new gmail account with client name OR we need create google App with your domain OR need to configure own SMTP.
Link: https://apps.google.com/
Search keyword: Get gmail for own domain.

 

Jquery load dialog after few seconds

  1. Dialog popup loading while page loading. To load the dialog popup after few seconds, we could use the below method.
  2. Dialog popup will display while page loading, we disable it through style while page loading and we could display it after few seconds through jquery.Disable all popup view through style as like below. Class will change based on your implementation.
    <style>
    .newsletter_main {
    display: none;
    }
    .ui-dialog-titlebar-close {
    display: none;
    }
    .ui-widget-overlay {
    display: none;
    }

    Also use below script to display the popup while page loading and enable the display view after few seconds from jQuery.

    <script>
    /* Load the dialog popup while page loading */
    jQuery( document ).ready(function() {
    jQuery( "#newsletter" ).dialog({
    closeOnEscape: false,
    show: 'fade',
    modal: true
    });
    });
    /* Display the popup content after few seconds */
    setTimeout(function(){
    jQuery( ".newsletter_main" ).css({"display":"block"});
    jQuery( ".ui-dialog-titlebar-close" ).css({"display":"block"});
    jQuery( ".ui-widget-overlay" ).css({"display":"block"});
    }, 3000);
    </script>
    /* Popup content Div */
    <div id="newsletter">
    Content Here
    </div>

 

 

Session not working in Ipage server

Please follow the below steps to fix the session not working issue within the Ipage server!

1. Log in to your ipage account.
2. Click on “CGI and scripted Language support”.
3. Select PHP scripting
4. Edit the php.ini file by finding the save_path by pressing ctrl +f

Change the
`session.save_path = “/var/php_sessions”`
to
`session.save_path = “/tmp”`

Google App configuration and Update MX record

We have configured Google APP Once followed below Steps. Also, we could reconfigure it into new server, while changing the server!

  1.  Go to Google APPS https://apps.google.com/ and Click “Get Started”.
  2. Enter some personal information and create the account.(Select your own User Name and Password)
  3. Conform your domain using “Google verification” link “Meta tag” or other method like below option.
    Google Verrification
  4. Update the MX record as like below image. We did this in iPage server.
    Update MX record

    Copy the text from below content.(Every one like Copy Paste!)

    Priority Name | Host | Alias Value | Destination
  5. Delete Existing MX Records within your server settings.Once Configured above steps Google APP worked fine!Then we have migrated the server into new server after some days! So, we have updated the nameserver within domain Manager and Mapped into new server!NOTE: “To find the existing Google APP MX record,  go to Apps > Google Apps > Gmail > User settings. Under MX records,  you could view the current MX records for your primary domain.”

    We need to create same mail ID(primary) with new server using Mail Control panel. And need to configure MX record only. We no need to do all verification steps.

    It will work fine as its before, once transferred the domain into new server!