Magento – custom redirect to home page not working in magento 1.7

cmsmagento-1.7url-rewrite

what iam trying to achieve is : to redirect a cms page to home page;
the cms page is accessible by domain.com/home
what i need is to redirect to domain/

i had already created a custom url rewrite rule from magento admin

ID Path :home(this is the url key of the cms page & this page is accessible via domain/home)
Request Path :domain/home 
Target Path : domain
Redirect : Permanent 301

But no luck ! im still getting the same cms page (No redirection ) tried clearing cache but still the same result.

Best Answer

Magento, rewrite manage work whenever Request Path & Target without base url.

Why, you did tried with htaccess 301 redirection.

It is every good idea use htaccess 301 if you using Apache as web server

# Permanent URL redirect - generated by 
Redirect 301 http://domain.com/home http://domain.com/

Or,you can use magento event observer.

In magento,when a Cms is call,then an event cms_page_render is fire before render layout.

And on this event using magento 301 redirection

(Mage::app()->getResponse()->setRedirect(Mage::getUrl(),301)->sendResponse())

and on basic of page identifier match $observer->getEvent()->getPage()->getIdentifier()=='home'

You can redirect to domain.com/home page to domain.com/

config.xml:

<?xml version="1.0"?>
<config>
......
  <global>
    <events>
      <cms_page_render> 
        <observers>
          <slash_home_to_domain>
            <type>singleton</type>
            <class>ModuleNameSpace_ModuleName_Model_Observer</class>
            <method>Home301redirect</method>
          </slash_home_to_domain>
        </observers>
      </cms_page_render>     
    </events>
  </global>
.....
</config>

Observer code:

<?php
class ModuleNameSpace_ModuleName_Model_Observer
{

    public function Home301redirect($observer)
    {
      $cmspage = $observer->getEvent();
      /* Condition match and redirect to home */
      if($cmspage->getIdentifier()=='home'):
  Mage::app()->getResponse()
      ->setRedirect(Mage::getUrl(), 301)
      ->sendResponse();
      exit();
      endif;
      return;
    }
}