I want to redirect http://olddomain.com to http://newdomain.com for my all urls..keeping the page on new domain same. What i mean to say is URLs such as below
http://olddomain.com/home/category/page.html
http://olddomain.com/home/mybook/page2.html
http://olddomain.com/login
should be 301 redirect to the new newdomain but same pages, like below
http://newdomain.com/home/category/page.html
http://newdomain.com/home/mybook/page2.html
http://newdomain.com/login
this is what i have in my .htaccess currently
RewriteEngine on
RewriteCond $1 !^(index\.php|img|public|robots\.txt) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
Please help me to do this cleanly and exlpain things in details since i am new in this.
also does someone know how much time search engines might take to move away from the references of my olddomain? i mean the old-domain urls in search queries should be replaced by new-domain urls... n old domain should go away from search engines.
A 301 signals a permanent redirect from one URL to another, meaning all users that request an old URL will be automatically sent to a new URL. A 301 redirect passes all ranking power from the old URL to the new URL, and is most commonly used when a page has been permanently moved or removed from a website.
A 301 Permanent Redirect permanently redirects one URL to another. You set up a 301 redirect using . htaccess to send visitors to a new URL and tell search engines that a page has moved so that the new page can be properly indexed. Some common uses of a 301 redirect with .
Add following code at the beginning of .htaccess -
RewriteEngine On
# Redirect Entire Site to New Domain
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^another.olddomain.com$ [NC]
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
Much simpler:
Redirect 301 / http://newdomain.com/
Replace your .htaccess file with that one line OR if you have access to it, put it in the apache conf file(s) for your old domain (I place it following the DocumentRoot directive).
See Redirecting and Remapping with mod_rewrite for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With