All posts by Rajmahendran P

Remove index.php from Magento URL in windows server

To remove the index.php from URL in magento normally we will use htaccess. But, it will work in apache server only. So, to remove the index.php in windows server, we need to use the below code in web.config file.

Save the below code within the “web.config” file and upload it into your magento root directory.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite> 
<rules>
 
 
 
<rule name="Remove index.php Rule" stopProcessing="true"> 
<match url=".*" ignoreCase="false" /> 
<conditions> 
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
</conditions> 
<action type="Rewrite" url="index.php" /> 
</rule>
 
 
 
</rules>
</rewrite>
</system.webServer>
<system.net>
<mailSettings>
<smtp>
<network host="localhost" />
</smtp>
</mailSettings>
</system.net>
</configuration>

Windows server web.config file to redirect all URLS into HTTPS

Used below code to redirect all URLs into HTTPS in windows server using web.config file.

 

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite> 
<rules>
 
 
<rule name="Force HTTPS" enabled="true" stopProcessing="true">>
<match url="(.*)" /> 
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
<add input="{REQUEST_URI}" pattern="^(.*)/ccadmin(.*)" ignoreCase="true" negate="true" /> 
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
 
 
 
<rule name="Remove index.php Rule" stopProcessing="true"> 
<match url=".*" ignoreCase="false" /> 
<conditions> 
<add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> 
</conditions> 
<action type="Rewrite" url="index.php" /> 
</rule>
 
 
 
</rules>
</rewrite>
</system.webServer>
<system.net>
<mailSettings>
<smtp>
<network host="localhost" />
</smtp>
</mailSettings>
</system.net>
</configuration>

Only below code worked for HTTPS redirection:

<rule name="Force HTTPS" enabled="true" stopProcessing="true">>
<match url="(.*)" /> 
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
<add input="{REQUEST_URI}" pattern="^(.*)/admin(.*)" ignoreCase="true" negate="true" />  <!-- Restrict the admin URLS from HTTPS redirection -->
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

 

 

Used below code to restrict particular URL from HTTPS redirection based on URL slug.

From the above code “MatchAll” value allow to work the HTTPS redirection once all the condition success within the <conditions> tag

logicalGrouping="MatchAll"

 

So, I have added two conditions like below within <conditions> tag.

  1. Check the loading URL is HTTPS or Not
  2. Check the loading URL slug
<add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
<add input="{REQUEST_URI}" pattern="^(.*)/admin(.*)" ignoreCase="true" negate="true" />  <!-- Restrict the admin URLS from HTTPS redirection -->

 

So, above code restrict the admin URL from HTTPS redirection.

Change magento contact form FROM address as User contact address

  1. In magento we could set the contact from FROM address in admin under Admin->Configuration->Contact->Email Sender(Field)

  2. In our case, we cant able to send email from Same address like XXX@knowledgebags.com to XXX@knowledgebags.com. So, we need to change the email from address as like user emails address. So, we did as like below!
  3. //Copy
    /app/code/core/Mage/Contacts/controllers/IndexController.php
     //Copy above file Into below location: 
    /app/code/local/Mage/Contacts/controllers/IndexController.php
    //You can comment out line 97, don’t need that anymore:
    //->setReplyTo($post['email'])
     //Comment out line 100, the one causing the problem:
    //Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),
     //Add a new line 101:
    array('email' => $post['email'], 'name' => $post['name']),
     //Save and you’re done!

4. Also, in my case Copy file into local folder not worked. So, we have did the test in /core folder itself and tested. Its worked fine.

NOTE: Also, we have changed all email sender admin as different address. For customer, order emails…etc

Magento configuration and Migration issues in windows server

We have faced below list of issues while using Magento in windows server.

  1. Magento 1.* PHP version should be 5.*
  2. url_rewrite – Need to use web.config based on IIS version
  3. In My case, url_rewrite not installed. To check this follow below steps.
    ->Start IIS Manager (Start >> Run, type inetmgr and hit enter).
    ->In IIS, select the Default Web Site.
    ->Under Features View, click URL Rewrite. (Its not displayed my case)
  4. Installed url_rewrite and fixed the issues.

    I will be continue soon….

“Invalid entity model” error while exporting csv file for products and Customers in Magento

Displayed “Invalid entity model” error, While Exporting  Products and Customers in Magento!

Its due to permission issue. Some time this error display in windows server.

Solution:

Open abstract class /app/code/core/Mage/ImportExport/Model/Export/Adapter/Abstract.php and replace line number 60(Line number will change some time)

//$destination = tempnam(sys_get_temp_dir(), 'importexport_');
//Change above like as like BELOW: 
$destination = tempnam(Mage::getBaseDir() . '/var/tmp/' , 'importexport_'); 

NOTE: Also, make sure “root/var/tmp/” folder have full permission.

Enable and Disable error log file in Plesk server

I have tried to Disable the error log file creation process through htaccess file using below code. But, its displayed “internal server error” in Plesk server. 

php_flag  log_errors off

So, updated settings as like below to Disable and Enable the error log in Plesk server.

If you would like to disable logging you may need to add it to the additional apache/nginx configuration found in
“Plesk >> Domains >> Domain in question >> Apache & nginx Settings >> Additional Apache
Directives”

OR, change the error logging in your PHP settings (“Plesk >> Domains >> Domain in
question >> PHP Settings >> error_reporting” ) to reduce what is logged. I have did through this option.

Please find the below image for more information.

Enable and Disable error log in Plesk server 1
enable-and-disable-error-log-in-plesk-server-1


Enable and Disable error log in Plesk server 2

enable-and-disable-error-log-in-plesk-server-2

Thank you.

Step to install and start the angularjs 2

Only three steps to start angularjs 2. Please find below:

  1. Install node JS and npm
    Download and install from below location. Latest version of node JS will have the npm.
    https://nodejs.org/en/download/
  2.  Install typescript.
    Use below comment to install the typescript.
    npm install -g typescript

  3. To the Install angularjs Libraries and Dependencies, please follow the below steps.

    – Download the project folder from here.

    – Copy into your computer.

    – Change the comment to above folder location like below.

        cd F:\angular\dev\angular-2-beta-boilerplate

        Then run “npm install” comment.( After few moment. )

        Start npm through “npm start” comment.

    Start work with angularjs 2. 

Windows server HTTP Error 500.50 – URL Rewrite Module Error while accessing the image

Hi All

We faced the problem while upload the image in windows server!

Image uploaded fine into server , but its not accessible from user-end through browser. Error displayed “500.50 – URL Rewrite Module Error

Reason:
The problem happens, when you use PHP to upload a file.  When you upload a file or image, PHP sends the file to a temporary directory on the hard drive (C:\Windows\Temp) and then copies it over to it’s intended directory(into site location).  Once the file has landed in the temporary directory, it is assigned the permissions of that directory. The problem is when Windows copies that file, it keeps the temporary directory’s permissions and doesn’t inherit your web directory’s permissions.

Solution:
1. Change the permissions on the temp folder(C:\Windows\Temp) giving IIS_IUSRS – write/modify. Find below image.

2. Change the path of the temp folder in the PHP.ini file to a folder that does have IIS_IUSRS write/modify permission.

windows temp folder permission change - 500.50 - URL Rewrite Module Error