I am looking to migrate from old domain to new domain.
I have my old domain olddomain.com
and new domain newdomain.com
pointing to same ip address for now.
I have Apache server inplace to handle requests.
How do I 301 redirect
all my
olddomain.com/*
&
www.olddomain.com/*
to
newdomain.com/*
Can I get exact regex or configuration that I need to add in htaccess
.
My newdomain.com and olddomain.com both are being serverd by same apache from same IP so "/" redirect might lead to cycles? And so was looking for effecient way
I tried
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost$ [OR]
# RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://comp16/$1 [R=301,L]
</IfModule>
And even tried adding in virtual host
RedirectMatch (.*)\.jpg$ http://comp17$1.jpg
But it does not redirect site when i hit localhost in browser to my computer name i.e comp16