I am just transferring over a WordPress site from Server 1 to Server 2.
The IP address of Server 1 points to example
(A record on DNS server)
The IP address of Server 2 points to www.example
(A record on DNS server)
During the migration, I want to type in www.example
and prevent any redirection - so that I can make sure that it has been set up correctly before
setting the A record for example
to point to Server 2.
There is a .htaccess
file on Server 2, but it isn't redirecting to example
. Just to make sure that it isn't, I renamed it to htaccess.bk
to make sure it doesn't kick in - but no success here.
Any idea what I need to do?
TIA!
I am just transferring over a WordPress site from Server 1 to Server 2.
The IP address of Server 1 points to example
(A record on DNS server)
The IP address of Server 2 points to www.example
(A record on DNS server)
During the migration, I want to type in www.example
and prevent any redirection - so that I can make sure that it has been set up correctly before
setting the A record for example
to point to Server 2.
There is a .htaccess
file on Server 2, but it isn't redirecting to example
. Just to make sure that it isn't, I renamed it to htaccess.bk
to make sure it doesn't kick in - but no success here.
Any idea what I need to do?
TIA!
What do you have set in the WordPress admin under Settings -> General and then WordPress Address
and Site Address
? Make sure these are both using the www.example
domain.
If you want to use an htaccess
rule, which will run before WordPress kicks in, there are plenty of answers on StakOverflow such as this one: https://stackoverflow/questions/4916222/htaccess-how-to-force-www-in-a-generic-way
Just put this code in your wp-config.php
file
define( 'WP_HOME', 'your_url' );
define( 'WP_SITEURL', 'your_url' );
In .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example [NC]
RewriteRule ^(.*)$ http://www.example/$1 [L,R=301,NC]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\ [NC]
RewriteRule ^(.*)$ http://example/$1 [L,R=301]
Note: You need just comment out these two lines in .htaccess file by using #
just putting before the line
RewriteEngine on
#RewriteCond %{HTTP_HOST} ^www\.example\ [NC]
#RewriteRule ^(.*)$ http://example/$1 [L,R=301]