Building WordPress on a different URl or in a subfolder is common practice for many. Most people will do it because they don’t want the website to be accessible to the general public until everything is ready.
When it comes time to migrate the WordPress site to the domain’s root or a different domain name, it’s easy to break things.
The most common problems people get are:
– Admin login redirect.
– Links redirect if using absolute path.
– In the worse case a blank screen.
Fortunately, it’s very easy to prevent the above problems.
First, if you use a folder within the main domain you would like to keep the WordPress web site on, it will be an additional security strength to keep your installation there. I know you actually want your web site to be directly accessible. You want visitors to type something like “domain.dlt” instead of “domain.tld/some-folder-name”.
You can get people to access the WordPress content directly by making the following update to a copy of your index.php from the installation’s root and paste it in the domain’s root:
require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );
require( dirname( __FILE__ ) . ‘/some-folder-name/wp-blog-header.php’ );
“some-folder-name” will be the name of your installation folder.
However, you will have to keep the same login URL like before and that will be another guess a hacker will have to make before guessing the username and password.
Second, if you are moving to a different URL, you have to make an update in your wp-config.php.
Open wp-config.php and just above the line “/* That’s all, stop editing! Happy blogging. */”, place the following lines of code and replace “newURL” with your new domain name.
If you decide to have your WordPress installation into a folder like in the first option, you will need to update the second line above into the following:
define(‘WP_SITEURL’, ‘http://newURL/some-folder-name’); // installation URL
keeping in mind “some-folder-name” will be your actual folder name.
It’s true it will be fairly simple to update your database, but it’s also very easy to break things there.
Before making any update please make a backup of your WordPress site (files and database).