Mobile app version of vmapp.org
Login or Join
Angela700

: How to 301 redirct all incoming requests to a domain to another domain? I have a WordPress blog running on an Apache2 server currently that I need to completely move to a new domain name.

@Angela700

Posted in: #Apache2 #Domains #Migration #Server #Wordpress

I have a WordPress blog running on an Apache2 server currently that I need to completely move to a new domain name.
www.somesite.com/ to www.someothersite.com
I need all requests to that domain to be redirected to a new domain name. Can this be done with .htaccess? If so what's the rule to be used?

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

3 Comments

Sorted by latest first Latest Oldest Best

 

@Frith620

The simplest way is to use a 301 redirect in a .htaccess file on the old domain which will point to the new domain. Use the following code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) www.newdomain.com/ [R=301,L]


Rememer to change newdomain.com to your actual new domain name. This code is dependant on mod_rewrite being installed in the Apache server. It usually is.

Another alternative is to use Rewritematch e.g.

RedirectMatch 301 (.*) www.abookaboutchina.com/

10% popularity Vote Up Vote Down


 

@Frith620

LazyOne beat me to it :) .... So what he said.... PLUS:

In the Wordpress Dashboard you have to find the setting where you put the domain name of your blog and change it to the new domain name. Otherwise, most links will point to the old domain.... which of course get directed back but it will obviously be inefficient.

10% popularity Vote Up Vote Down


 

@Shelton105

If URLs are exactly the same and the only difference is the domain name, then it is very easy to do. Just place this line in .htaccess in website root folder of somesite.com:
Redirect 301 / www.someothersite.com/

The above rule will redirect (301 Permanent Redirect) ALL requests to a new domain using the same URL and preserving the query string.

At the same time you may need to disable any existing rewrite rules in that .htaccess file, otherwise WordPress may be processing all rules before such redirect occurs (RewriteRule has higher priority than Redirect).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme