Best way to change domain names - dns

I have a blog which i get about 1200 visits a month lets say the blog domain name is.
exampleblog.com
What i want to do is complete change the domain name to say.
iamsam.com
What is the correct way to do this should i map the domain iamsam.com to my exampleblog.com account on my hosting then put a 301 redirect in the htaccess to redirect traffic to the correct domain ie.
Options +FollowSymlinks
rewritecond %{http_host} ^exampleblog.com [nc]
rewriterule ^(.*)$ http://www.iamsam.com/$1 [r=301,nc]
Is this the correct way to do this???
Can someone advise me thanks

Yes, that is exactly the way to do it, assuming the URL scheme for the new domain is exactly the same as the old domain.
You might also want to capture users that use the old address and display some sort of notification on the new website, so that they'll notice the change and update their bookmarks.

Related

How to redirect entire domain to new domain except homepage via htaccess

So I have found some questions that are close to what I need, but I haven't found exactly what I'm looking for.
While I've worked with htaccess files in the past, it's pretty much been just copying and pasting code that is proven to work, or just doing simple 301 redirects. To be honest, I get pretty confused when looking at htaccess rewrite rules, so unfortunately are not going to be able to do from scratch. So I'm really hoping there is someone kind enough to provide a code example just using placeholder domain names.
Here is my situation. I'm doing work for a company who has split up into different divisions (4). So they want to take the site on their current domain, move it to a different domain. Then put up a simple html splash page on the old domain that provides links to the 4 different sites they will have (one of those being what was the old site on a new domain).
So I need to redirect everything from olddomain.com to newdomain.com with the exception of the homepage. Not sure if this matters, but site that was on the old domain was a WordPress site so technically is index.php. But the new site/splash page is named index.html.
Thanks in advance!
So I need to redirect everything from olddomain.com to newdomain.com with the exception of the homepage.
You can use this rule in the site root .htaccess of olddomain.com:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?olddomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !/(css|js|images)/ [NC]
RewriteRule . http://newdomain.com%{REQUEST_URI} [L,NE,R=301]
RewriteRule . will match everything except the home page just make sure this rule is the first rule in your .htaccess.

Shall i implement the 301-redirection method to my site inner pages?

Actually I am working in a one url, now my client told me to change the domain name, so I have planned to do 301-redirection for my home page in a new domain. But i have worked for both home and inner pages on my previous site. Is it recommended to do the 301-redirection for my inner pages too, please help me....
There should be an option in your hosting panel to manage redirects you can then redirect the whole domain, and send it to the new domain. I hope this helps.
Yes, it is recommended that you redirect all of your existing pages/urls to new domain. This will retain your SEO ranking and also the customers who've bookmarked earlier domain.
However, instead of doing a redirect of each individual URL, you could use the power of .htaccess file and put below code to catch all the request coming for old domain (lets say example.com) and redirect them to corresponding pages on new domain (lets say example.org)
You could use something like below
# Detect if the request was raised for old domain
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.org/$1 [R=301,L]
Hope it will help.

.htaccess to RewriteRule or Redirect from one dynamic url domain to another domain

I have barely any knowledge of .htaccess but I fumble with code. :)
I have one CMS with 2 domain names, each domain pulls a totally different site but managed through one back end. The sites are related so there is no real secrecy - a parent and a child.
I have one extension that must operate on one domain only. It handles payments through PayPal and PayPal restricts accounts to only one domain per organization. It is used with both domains.
I have relative linking throughout the back end so menu and article links to anything that has to do with that extension carry the domain from which it is generated. I need a way to automatically direct anything from the child site for just that extension to the parent site, both messy and SEF links.
So, here is an example:
child.com/index.php?option=com_civicrm&task=civicrm/pcp/info&reset=1&id=1
to go to
parent.org/index.php?option=com_civicrm&task=civicrm/pcp/info&reset=1&id=1
and
child.com/wildcard/wildcard
to go to
parent.org/wildcard/wildcard
The extension is com_civicrm. I need any variables after it to work. These may and may not be ".../pcp/..."
And if this matters, the back end only differs by parent.org/administrator/index.php?option=com_civicrm... so I don't want to accidentally direct the back end to the front end by accidentally losing the "administrator".
Thanks in advance,
Helen
RewriteEngine On
RewriteBase /
# if domain is child.com, and url is '/wildcard/wildcard', redirect to same url on parent.org
RewriteCond %{HTTP_HOST} child\.com$
RewriteRule ^wildcard/wildcard$ http://parent.org/wildcard/wildcard [R=302,L]
# if domain is child.com, and querystring contains 'option=com_civicrm', redirect to same url on parent.org
RewriteCond %{HTTP_HOST} child\.com$
RewriteCond %{QUERY_STRING} option=com_civicrm
RewriteRule (.*) http://parent.org/$1 [R=302,L]
Happy fumbling :-)

htaccess redirection from messy url to clean one

An email blast was sent with some urls to my site, unfortunately somehow the links are showing some tracking from the tool i used and the site is choking on the URLs.
how can I redirect the incoming requests from
http://www.mysite.com/?utm_source=mysite+List&utm_campaign=xxxxxxxx-blah_blah_blah_blah&utm_medium=email#!/clients/myclient/
to
http://www.mysite.com/folder/page/
I tried using
Redirect http://www\\.mysite\\.com/\\?utm_source=mysite\\+List\\&utm_campaign=xxxxxxxx-blah_blah_blah_blah\\&utm_medium=email#!/clients/myclient/ http://www\\.mysite\\.com/folder/page/
but it didnt work.
the site already has some rules so it should redirect only when needed and let the other rules work
how can i achieve that?
thanks in advance
I don't know how precise you need to be, but the reason it isn't working is because it doens't understand query strings. You need to use a rewritecond and rewrite.
RewriteCond %{QUERY_STRING} ^utm_source
RewriteRule (.*) http://www.mysite.com/folder/page/? [R=301,L]
this will redirect all traffic if it has utm_source in the query string.

Unable to show siteA's content at siteB by domain masking

I have a domain www.siteA.com, which uses Joomla, while the domain www.siteB.com is empty.
I would like to show the content of the domain www.siteA.com at www.siteB.com.
I tried to solve the problem first by making a domain redirection by .htaccess, but I could not show SiteA's content at SiteB.
How can you show the contents of mysiteA.com at mysiteB.com by domain masking in .htaccess?
You really should be doing this by CNAME-ing the domain, but if you really want to use .htaccess you can do what #Unkwntech suggests
Edit: It would just look like
www.siteB.com CNAME www.siteA.com
Whichever way you do it (CNAME or htaccess) you're probably going to get an SEO penalty for duplicate content.
RewriteEngine On
RewriteRule ^.*$ http://www.siteA.tld/$1 [NC]
This should rewrite every request to siteA.

Resources