Server

Redirecting all URLs to .com rather than .biz, .co.uk, .info

I was having this problem with my current site. I have several domains like

ukwhitegoods.biz

ukwhitegoods.co

ukwhitegoods.co.uk

ukwhitegoods.com

ukwhitegoods.eu

ukwhitegoods.info

ukwhitegoods.me.uk

Even the problem was Google was indexing all these pages separately and which is not good from the SEO perspective. Therefore, we

This thing is also called as CANONICAL DOMAIN

I used the following code to force all URLs to go to .co.uk

RewriteBase /
 
RewriteCond %{HTTP_HOST} !^(www\.)?ukwhitegoods\.co\.uk$ [NC] ////This means was anything other than this pattern is fired, follow the rule

///NC means case sensitive URL
RewriteRule ^(.*)$ http://www.ukwhitegoods.co.uk/$1 [R=301,L] ////Its a permanent redirect and LAST RULE

So now all my landing pages goes to ukwhitegoods.co.uk

Advertisements

.htacess redirect and rewrites

I am writing this blog for a very simple usage of htaccess for redirects and rewriting the url

The first things that needs to be understand for the htaccess REWRITE and REDIRECT modules are the synstax

 

marks the start of line. It means anything that starts with

$ marks the end of line.

(.*) means any character within the url. This gets replaced by $1 at first occurence and $2 as second occurence

L means last code and do not execute anything after this.

R means redirect the page, so the url will be changed. However if you do not add that, it will be same.

 

 

Now here are some sample code

 

RewriteRule ^styles/ - [L,NC]

Now the above code means that if any url starts with style, just let it go through it. for example

http://www.google.com/styles

 

RewriteRule ^resources/image/thumb/(.*)/?$ /download/file.php?id=$1&t=1 [NC,L] # Handle product requests

If any url starts with resources/image/thumb/(.*){THIS COULD BE ANY STRING}/

http://www.google.com/resources/image/thumb/65/

http://www.google.com/resources/image/thumb/was5/

http://www.google.com/resources/image/thumb/adhg5/

Go to looking for

http://www.google.com/download/file.php?id=$1&t=1

Here $1 is (.*){THIS COULD BE ANY STRING}/

http://www.google.com/download/file.php?id=was5&t=1

http://www.google.com/download/file.php?id=65&t=1

 

 

RewriteRule ^resources/image/(.*)/rokbox.jpg?$ /download/file.php?id=$1&mode=view/rokbox.jpg [NC,L] # Handle product requests

RewriteRule ^(.*)/$ $1.html [R,NC,L] # Permanent Move
RewriteRule ^(.*)/(.*)$ $2 [R,NC,L] # Permanent Move

 

 

To exclude a file from htaccess rule: follow this

RewriteCond %{REQUEST_URI} !^/google89b2a81fd1609a6e\.html$

Magento Order email not sent but cron job running | exception ‘Zend_Mail_Transport_Exception’ with message ‘Missing To header’ in /var/www/html/shop/lib/Zend/Mail/Transport/Sendmail.php:182

Solution 1

Are you getting following message in your magento shop /var/exception.log

2015-10-28T00:05:02+00:00 ERR (3):
exception 'Zend_Mail_Transport_Exception' with message 'Missing To header' in /var/www/html/shop/lib/Zend/Mail/Transport/Sendmail.php:182
Stack trace:
#0 /var/www/html/shop/lib/Zend/Mail/Transport/Abstract.php(337): Zend_Mail_Transport_Sendmail->_prepareHeaders(Array)
#1 /var/www/html/shop/lib/Zend/Mail.php(1194): Zend_Mail_Transport_Abstract->send(Object(Zend_Mail))
#2 /var/www/html/shop/app/code/core/Mage/Core/Model/Email/Queue.php(236): Zend_Mail->send()
#3 [internal function]: Mage_Core_Model_Email_Queue->send(Object(Mage_Cron_Model_Schedule))
#4 /var/www/html/shop/app/code/core/Mage/Cron/Model/Observer.php(326): call_user_func_array(Array, Array)
#5 /var/www/html/shop/app/code/core/Mage/Cron/Model/Observer.php(72): Mage_Cron_Model_Observer->_processJob(Object(Mage_Cron_Model_Schedule), Object(Mage_Core_Model_Config_Element))
#6 /var/www/html/shop/app/code/core/Mage/Core/Model/App.php(1357): Mage_Cron_Model_Observer->dispatch(Object(Varien_Event_Observer))
#7 /var/www/html/shop/app/code/core/Mage/Core/Model/App.php(1336): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Cron_Model_Observer), 'dispatch', Object(Varien_Event_Observer))
#8 /var/www/html/shop/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('default', Array)
#9 /var/www/html/shop/cron.php(77): Mage::dispatchEvent('default')
#10 {main}
As you might understand that the problem is due to sender missing. But, in Magento 1.9, this is serious problem as it might stop all your order emails to stop sending. The solution is finding the order with the null email address and deleting the email_queue cron job of that order. Here are the tricks

First find the order that have no email with following command


 SELECT *
 FROM `sales_flat_order`
 WHERE `customer_email` IS NULL
 

Now I recommend to update that order

UPDATE `sales_flat_order` SET `customer_email` = '*******@yahoo.com' WHERE `sales_flat_order`.`entity_id` =YOUR_ORDER_ID ;

Now find this order in core_email_queue


select * from `core_email_queue` WHERE entity_id='YOUR_ORDER_ID'; ///Note this is not order number. 
////you can get order id from the url of admin of order

There should be 2 entries if you send yourself as well order copy

And now find the corresponding in core_email_queue_recipients


select * from `core_email_queue_recipients` WHERE message_id='MESSAGE_ID_FROM_core_email_queue'
select * from `core_email_queue_recipients` WHERE message_id='MESSAGE_ID_FROM_core_email_queue'

If you do not have message_id in core_email_queue_recipients, then you should delete it from core_email_queue

 


DELETE FROM core_email_queue WHERE message_id='MESSAGE_ID_MISSING_FROM_core_email_queue'

Solution 2: Quick & Dirty one

Other quick and dirty solution which I have not tried, but you can try on test server first is to


TRUNCATE core_email_queue_recipients;
TRUNCATE core_email_queue;

This should clear all your email queues but will delete the working email queues too.

If you want to run two instance of apache, there is a trick. I tried this for easyphp & XAMPP on windows. I was already having a working XAMPP server on my windows PC. I installed easyphp on the same PC. Now when I tried to start apache it gave that firewall has block the port and therefore cannot start apache. you just need to change the port for apache . Edit the file \apache\conf\httpd.conf and edit l following line

Listen 12.34.56.78:80
to
Listen 127.0.0.1:1024

You can also try any other number. Also when you open the browser to run any script: Like

http://localhost:1024/info.php

or

http://127.0.0.1:1024/info.php

File info.php

<?php
phpinfo();
?>