Several reasons to change the URL
The following are instructions for moving a WordPress installation from one URL to a different one. There are different cases for moving a WordPress install, as shown below.
Use your own URL instead of example.com, obviously.
3. Upload the file back to your site, in the same location. FileZilla offers a handy “edit file” function to do all of the above rapidly; if you can use that, do so.
]]>
Case #1 — Moving from a subdirectory
The first case is when a WordPress site moves from a sub-directory to its parent domain. For example:- Move from https://cozmot.com/blog to
- https://cozmot.com
Case #2 — Adding or removing www
Another reason to update your URLs is if you need to add or remove www from your domain. For example, if you’re using Cloudflare with DreamHost, you need to add www to your domain. So if it was previously example.com, you would change it to www.example.com. After adjusting the URL, you may also see a browser redirect error when viewing your site. It may say “Too many redirects” or “The page isn’t redirecting properly”.Case #3 — Adding ‘https’ to the URL
If you’re using an SSL certificate, the first part of the URL changes from ‘http’ to ‘https’. If you’ve already made this change, you are not able to log in since WordPress is configured to use the old URL.Case #4 — Moving to a new domain
The last case is when a WordPress site moves from one fully hosted domain to a different one. For example:- Move from https://example.com to
- https://cozmot.com
Option 1 – Changing the HOME and SITE URL using phpMyAdmin
If you’ve already made any of the changes above, you’re not able to log into your dashboard. You can instead use phpMyAdmin to update the HOME and SITE URLs. Visit the following article for more information on how to log into phpMyAdmin:- Finding your phpMyAdmin login credentials
- Open phpMyAdmin.
- Click your database in the left pane. Several tables appear below it. Click on your wp_options table.
- Locate the siteurl and home rows. Click the pencil icon next to each to edit.
- When you scroll over these options, “browse” will appear.
- Click the pencil icon next to each to edit.
- Alter the URL by typing in a new one.
- Click the Go button to save the settings. Do this for both the ‘siteurl’ and ‘home’ options.
- Changing all URLs in your WordPress database
Option 2 – Changing the URLs in your wp-config.php file
You can also change the URLs in your wp-config.php file. This is a little easier than editing your database and will give you immediate access to your site.
The following assumes your Home and Site URL should be ‘example.com’.
- Log into your site using FTP or SSH.
- In your WordPress directory, edit the file titled wp-config.php.
- Creating and editing files via FTP
- Creating and editing a file via SSH
- In that file, add the following lines just above /* That’s all, stop editing! Happy blogging. */.
1234define('WP_HOME','http://example.com');define('WP_SITEURL','http://example.com');
- If you visit your site now, you’ll see you can log in.
- Changing all URLs in your WordPress database
Edit functions.php Edit functions.php
If you have access to the site via FTP, then this method will help you quickly get a site back up and running, if you changed those values incorrectly.- FTP to the site, and get a copy of the active theme’s
functions.php
file. You’re going to edit it in a simple text editor and upload it back to the site. - Add these two lines to the file, immediately after the initial “<?php” line:
update_option( 'siteurl' , 'http://example.com' ); update_option( 'home' , 'http://example.com' ); |
Verifying the new HOME and SITE URL
If you used options #1 above, the HOME and SITE URLs were updated in the database. You can confirm your site is now using the correct URLs in your dashboard.
-
- Log into your WordPress Dashboard.
- Navigate over to Settings > General.
- Here you’ll see the HOME and SITE URL your WordPress site is configured to use.