Redirect To Another Host With Query String Htaccess

Redirect To Another Host With Query String Htaccess

If you wish to redirect your current domain, along with its query strings, to another host or domain, you can do so with the following .htaccess code. Just replace www.newdomain.com with whatever domain you wish to redirect to

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) http://www.newdomain.com%{REQUEST_URI} [R=302,NC]

 

Enjoyed the content ? Share it with your friends !

Redirect Old Domain To New Domain With .htaccess

Redirect Old Domain To New Domain With .htaccess

Assuming that your web server runs on Apache, which is pretty much the norm for any shared hosting service out in the wild, here’s how you can redirect your old domain name to a new one, while keeping your SEO juices.

Using any file editor available, edit the .htaccess file at the root folder, which is usually public_html .Add the following to the very start of the file, regardless of whether your .htaccess is empty or not

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^olddomainhere.com$ [OR]
  RewriteCond %{HTTP_HOST} ^www.olddomainhere.com$
  RewriteRule (.*)$ http://www.newdomainhere.com/$1 [R=301,L]
</IfModule>

The above will redirect the homepage, and any other pages. For example, the following

1. http://olddomainhere.com/
2. http://www.olddomainhere.com/
3. http://olddomainhere.com/redirect-old-domain-to-new-domain-with-htaccess

Redirects to the following respectively

1. http://www.newdomainhere.com/
2. http://www.newdomainhere.com/
3. http://www.newdomainhere.com/redirect-old-domain-to-new-domain-with-htaccess

Should you require any assistance, let me know in the comments below and I will try my best to help.

Enjoyed the content ? Share it with your friends !