I have changed domain on the Magento store, however I need to still keep old domain urls accessible and redirected to new domain urls.

for example. old-domain.com/products should redirect to new-domain.com/products

This is from my current htaccess

Options +FollowSymLinks
RewriteEngine on

#  RewriteCond %{HTTP_HOST} ^old-domain\.com$ [OR]
#  RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$
#  RewriteRule (.*)$ http://www.new-domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC]
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

as you can see, I tried 2 versions,

RewriteCond %{HTTP_HOST} ^old-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$
RewriteRule (.*)$ http://www.new-domain.com/$1 [R=301,L]


RewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC]
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]

But none of them work. Yes, I have disabled caching in Magento and yes, just in any case, I still flush the cache in Magento and I clear cache in browser too.

I dont know if this matters but anyways. Both new and old domains are controlled by godaddy, with its default nameservers, and both domains have @ record pointed to my server IP address.

Please help : )

Note: of course, I have real domains in the htaccess instead of old-domain.com and new-domain.com

Currently any kind of url with old domain, just redirects to homepage of new domain.

1 Answer 1


Let's try this one:


should be useful. Have you enabled mod_rewrite?

Oh I found reason why it didn't works for You. Please try something like:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.new-domain.com$ [NC] 
RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]


here are parameters You can use:

  • C (chained with next rule)
  • CO=cookie (set specified cookie)
  • E=var:value (set environment variable var to value)
  • F (forbidden - sends a 403 header to the user)
  • G (gone - no longer exists)
  • H=handler (set handler)
  • L (last - stop processing rules)
  • N (next - continue processing rules)
  • NC (case insensitive)
  • NE (do not escape special URL characters in output)
  • NS (ignore this rule if the request is a subrequest)
  • P (proxy - i.e., apache should grab the remote content specified in the substitution section and return it)
  • PT (pass through - use when processing URLs with additional handlers, e.g., mod_alias)
  • R (temporary redirect to new URL)
  • R=301 (permanent redirect to new URL)
  • QSA (append query string from request to substituted URL)
  • S=x (skip next x rules)
  • T=mime-type (force specified mime type)
  • Thanks for response. Yes, mod_rewrite is enabled of course :) I dont see any new solutions on that URL that you posted that I could use :(
    – Domeniko
    Jan 15, 2018 at 8:34
  • One big thing: is apache project directory set directly to Your project catalog (eg /var/www/html/) or to pub catalog (/var/www/html/pub)? Jan 15, 2018 at 8:38
  • website is directly in /public_html folder if thats what you mean
    – Domeniko
    Jan 15, 2018 at 8:48
  • Im asking about directory specified in apache vhost to this project Jan 15, 2018 at 8:56
  • I confirmed with my hosting, the doc root is public_html where the magento files are
    – Domeniko
    Jan 15, 2018 at 9:22

Your Answer

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

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