I have moved my Magento files from sub-domain "/magento" to root folder successfully, and I created and generated the google sitemap from admin catalog > google sitemap, and I added "Disallow: /magento/" to robots.txt file, but I still see "www.mydomain.com/magento/‎" shows when I do seach in google by writing "site:www.mydomain.com"

I tried also to remove robots.txt from root and I went to System > Configuration > General > Design, and at Default Robots I choose "INDEX, FOLLOW"

Still I see "www.mydomain.com/magento/‎" appear in google search

I hope someone can guide me with a solution it would be appreciated.

3 Answers 3


In your .htaccess file, you would use this line to 301 redirect correctly:

RedirectPermanent /magento/ http://www.Your_Domain.com/

That will 301 redirect everything that was in the /magento directory to your main domain without the sub-directory. It will properly keep all the URLs intact that were in the magento directory. Nice and clean.

  • After doing your redirection I got 503 error "service not available" on both front end and back end, I had to google the problem and I found that I have to delete maintenance.flag file from root directory to get back everything, it was hardest 5 minutes I felt
    – Khalil
    Apr 20, 2014 at 23:00
  • I did your solution again and it works without any problem, Thank you
    – Khalil
    Apr 20, 2014 at 23:42

Just to be clear ALL indexed urls in Google stays there for minimum 90 days. Second in your root's .htaccess file just add Disallow: /magento/ to prevent search engines to crawl or index that directly any further. Finally just to be safe add a 301 Redirect to redirect all who ever land up on /magento/ directory to your store's home page.

Ensure that under no circumstances anyone can access /magento/ directory, if they do they are redirected to store's home page.


First of all you should allow /magento/ in robots.txt because Google shouldn't index this pages and it shouldn't know about that your pages moved to different url. Next step - you should re-check your url configuration(it may be rewritten on other scopes), flush cache, reindex URL rewrites and re-generate sitemap.xml file and check it for correct url's. Than you should make 401 redirect from yourdomain.com/magento/something.html to yourdomain.com/something.html. You can make it via .htaccess(if you using Apache) or server configuration if you using nginx. Than you should try go to https://www.google.com/search?q=site:yourdomain.com and try go to few links, if it's redirecting correct - great. If no - you should re-check your redirect configuraion. After all changes you should re-upload sitemap.xml in your Google Webmaster tools.

  • Thanks Igor for the detailed answer, just need to know how to do 401 redirection what I have done is that: ` RewriteCond %{THE_REQUEST} ^.*/magento RewriteRule ^(.*)magento$ cabas-durables.fr/$1 [R=401,L] ` I think this is wrong redirection
    – Khalil
    Apr 19, 2014 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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