Best way to permanently redirect

I have set up a webshop at Let’s say my store is located at

I would like to run it on my own unique domain - let’s call it

I’ve now made a CNAME record to point to - which works just fine.

My problem is that (without “www”) does not work.

My question is what would be the best way to permanently redirect “” to “”? I’m looking for the best solution when also taking SEO into account. I don’t want to upset Google :slight_smile:

Thanks in advance

Write this code in your .htaccess

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^ [nc]
rewriterule ^(.*)$$1 [r=301,nc]

Thanks alisaparkar,

Looks like a good solution. Do you know if this would also be accepted by Google and the other search engines?

Yes, 301 redirects indicate to google, “Please look over here instead.”, which Google happily accepts.

Although the code above works fine I’d suggest a few minor tweaks to make it a bit more efficient.

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\\.com [NC]
RewriteRule .?{REQUEST_URI} [L,R=301]

Thank you both.

I’ll try it out.