I have changed my domain name. I want to redirect users when they type old URL...

suppose Old URL was: Google and New old URL is : googled

So when a user enters my old URL, it should redirect to new URL..

can we manage this through magento admin area?

or we have to write it in magento htaccess file?


If you simply want to redirect your old domain, to the new domain, and the pages are all the same paths, you'd be best to get this done via .htaccess and rewite rules

This will work for that:

# Redirect all pages from olddomain.com
# to newdomain.com
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^olddomain.com$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

Remember that for any type of URL rewrite, using magento's internal rewrite system is a lot more 'expensive' on resources than making use of webserver rewrites.

I generally try and use .htaccess rules if the rewrite is to do a redirect (301's, 302's etc) - way less resource intensive.

If, however, you have to use magento rewrite system, entering a lot of URLs via the admin can be tedious, and time consuming.

What you can do instead, is to do it programatically Either by a basic extension, that purely runs a setup script, or via a shell script.

The install script would be something like this:


$installer = $this;

$urlMap = array("old url path" => "NEW PATH",
"old-url-path.html" => "new/url/path.html",
"some/more/url/changes" => "another-new-path.html",

try {

    foreach($urlMap as $old => $new) { 
} catch (Exception $e) {

  • Proxiblue that's what i want... Can you please tell me... can i write this from custom module? – Arslantabassum Feb 18 '15 at 14:38
  • Yes, you can place the code given into your module install scripts. ref: inchoo.net/magento/… if you are not sure about how that works. – ProxiBlue Feb 18 '15 at 14:44
  • Done with domain name... Now I have diffrent urls... because i moved from opencart to magento.. so every product url is diffrent... suppose i have product url in opencart www.example.com/index.php?product=33 and in i've www.example.com/index.php/lock.html and same as many others.... i've created a module that takes all old urls and new urls and saves in database table.. but having issue to write those old and new urls from db table to .htaccess file... Hope you understand my problem... – Arslantabassum Feb 19 '15 at 12:37
  • How many urls are we talking about here? 1000's? If not to many, simply use magento's rewrite system, as explained in the second part of the answer. However, as you explained in your comment, you are really looking for ID to PRODUCT mappings. I suggest you read up on RewriteMaps (httpd.apache.org/docs/2.4/rewrite/rewritemap.html) - especially see the section on 'txt: Plain text maps' - their example is the exact thing you want (flipped). Unfortunately this is out of scope for this stack, and you'd be best to ask webmasters.stackexchange.com for more help – ProxiBlue Feb 19 '15 at 16:08

You can do it in either Magento or with Apache rewrite rules. If the URLs are all the same with just a different domain, then Apache rewrite would be the easiest. If you have to map all the old URLs to a completely different URL structure, then you might want to use Magento. The only issue you are going to have is setting up the second domain on the same store. You may need to create a new store for the purpose of handling the redirects. You should also look into rewritemap. It will have better performance than Magento redirects.


In either case, be sure to 301 redirects.

  • I have many URLs to redirect? what should be the best? and please give an example , how to do that? – Arslantabassum Feb 18 '15 at 7:00
  • Here is a video tutorial on Magento rewrites. You will want "custom". youtube.com/watch?v=h0Urg7T5iR8 – Daniel Smith Feb 18 '15 at 7:10
  • @Arslantabassum: define : many. Is it just the domain that changed? so actual url path is the same, in all the many urls? – ProxiBlue Feb 18 '15 at 8:14
  • @ProxiBlue I have different urls.. – Arslantabassum Feb 18 '15 at 14:13
  • @Arslantabassum, a bit confused, as this does not match your question, which states that you just changed your domain. That would then not imply many different URLs that require rewrite since the structure of your site would remain. – ProxiBlue Feb 18 '15 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.