Redirecting Domains With htaccess
Yesterday, we explored how to redirect a domain from your domain registrar. Today, I’ll share some code how to do the same thing by editing the htaccess file in your old website. This only works if you have a web host running an Apache server. Don’t sweat over this small technicality. Usually, if you have Linux based web host, chances are this will work.
So here’s the code. It’ll redirect the domain and also retain any page name trailing the domain.
Example http://olddomain.com/somepage.html will be redirected to http://newdomain.com/somepage.html
Make sure you change out the olddomain.com and newdomain.com for your own domain names.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*olddomain\.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
Technorati Tags: apache, domain, Tech support
Do You Want A Hands-Free Business?
Then get this guide to help you systemize your business so you'll have more time working on your business.
Hey! I want to make sure you know what you're getting here. In addition to the guide, you will also receive our memo that includes special offers, announcements and of course actionable information.