What to Do If You Can’t Change the Site and WordPress Address (URL)

>What to Do If You Can’t Change the Site and WordPress Address (URL)
  • What to Do If You Can't Edit the Site and WordPress Address (URL)

We recently had a client who has implemented an SSL certificate for his website, but he didn’t know how to perform a proper redirection from HTTP to HTTPS, so he asked for our help.

While working on it, we noticed that the Site Address (URL) and WordPress Address (URL), found in General -> Settings, were grayed out, therefore they couldn’t be changed.

This usually happens when someone moves a WordPress site, but forgets to delete a couple of lines of code.

So, in this article, we’ll show you what file you need to edit in order to be able to change your Site Address and WordPress Address from within the General settings. It’s easy, don’t worry!

Update: If you’ve moved from HTTP to HTTPS, and you’re using WordPress MultiSite, check Craig’s comment below.

affiliate-disclosure-banner

Edit your wp-config.php file

You’ll need to access your WordPress files and edit the wp-config.php file.

Backup your wp-config.php file in case something goes wrong! Just download it somewhere on your hard drive.

For our example, we’ll use cPanel. What you need to do is to:

  • Log in to cPanel and open your File Manager;

cpanel file manager

  • Select public_html;

public_html

  • On the right, find the wp-config.php file. Once you’ve found it, right-click on it and select Edit;

edit wp-config.php

  • Now search for these lines of code and delete them (if they are there, of course):

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

  • Save changes.

You’ll find your site’s URL there, of course, not “example.com”.

To quickly find them, just press Ctrl+F (Command+F on Mac) and insert a piece o code (e.g. define('WP_HOME)) and hit Enter. That will send you directly to the code.

After you delete that code, your Site Address (URL) and WordPress Address (URL) shouldn’t be grayed out anymore, and you can edit them.

If the code is not there, check the functions.php file!

Edit your functions.php file

You can edit your functions.php file through cPanel, a third party software, like FileZilla or SmartFTP, or the WordPress Editor.

We’ll use cPanel and the Editor for our examples.

Backup your functions.php file in case something goes wrong! Save it somewhere on your hard drive.

1. Through cPanel

  • Access the File Manager as in the above example;
  • Go to public_html -> wp-content -> themes -> select your theme’s folder;

wordpress themes folder

  • Once you’ve selected your theme’s folder, search for functions.php on the right, right-click on it and select Edit – the same process as above;
  • Now search for these lines of code and delete them:

update_option('siteurl','http://example.com');
update_option('home','http://example.com');

  • Save changes.

You can always use the Ctrl+F (Command+F on Mac) command to quickly find them, as I mentioned above.

2. Through WordPress Editor

You can find this feature inside your WordPress Dashboard.

This feature might be unavailable for security reasons. Some security plugins, like iThemes Security, have an option that allows you to disable the File Editor.

In order to access this feature, you need to:

  • Go to Appearance -> Editor;

wordpress theme editor

  • Once there, search for Theme Options (functions.php) on the right and click on it;

functions.php in theme editor

  • Now search for the lines of code and delete them:

update_option('siteurl','http://example.com');
update_option('home','http://example.com');

  • Save changes.

That’s it!

Conclusion

Be careful when you change your Site Address and/or WordPress Address, because it can affect your website. Also, be careful when you edit those files I’ve mentioned. Don’t forget to back them up!

If you’re not sure what you are doing, please ask someone with more experience to help you! Better safe than sorry, no?

If you have any thoughts to share with us, or you want to ask us something, please leave a comment!

By |2018-06-20T07:28:47+00:00August 2nd, 2015|Customization, Fix, WordPress|15 Comments

15 Comments

  1. GG November 29, 2016 at 6:08 AM - Reply

    Thx for the tip.

  2. Marcus April 13, 2017 at 3:17 PM - Reply

    Good tip. After multiple Google searches I found the answer to the greyed out option in WP panel.

    Cheers.

  3. Richard Daniels May 1, 2017 at 10:55 PM - Reply

    Thank you very much. I was about ready to throw my PC out of the window 🙂

  4. Craig V May 4, 2017 at 5:30 AM - Reply

    Thanks for the article. Have moved my site in the past from one host to another (7 years ago) and only recently implemented site-wide SSL. All is working perfectly, but I still have the original problem as outlined here (Home and Site URL are both still http:// rather than https://).

    I removed the two sets of code precisely as outlined here when I did the move last year and have checked again today – that code is definitely absent from the named php files. Still, my fields are grayed out.

    The site is under Network Admin installation but all works otherwise perfectly. Is there anything else that could be causing this? Big thanks for your help and for any ideas!

    • Craig V May 4, 2017 at 6:14 AM - Reply

      I’ll add that I also edited my .htaccess file when I made the site-wide change to SSL, adding the ‘HTTPS ON’ rewrite module to the top of the page, like so:

      RewriteEngine on
      RewriteBase /
      RewriteCond %{HTTPS} !on
      RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R]

      This has worked perfectly. However, several of my pages are failing to show at all, probably because of the above change. This means that when you try to access the page (eg. https://examplesite.com/examplepage), it fails to work and just dumps you back to the main page.

      I’m pretty sure that changing my Site Address to https would resolve this – if only it wasn’t grayed out! Thanks again for any thoughts or ideas, I’m pretty much out of them myself!

    • Craig V May 4, 2017 at 9:04 AM - Reply

      I hope this is considered useful info for others finding the site in future, rather than simple spamming of the Comments section! I believe I have worked it out, finding the answer on the WP Codex pages (specifically, https://codex.wordpress.org/Changing_The_Site_URL.

      The article began with the same tips as in your post above, but included an Alert! box underneath, which stated: “Alert! These directions are for single installs of WordPress only. If you are using WordPress MultiSite, you will need to manually edit your database.”

      Ah ha!

      Scrolling down, I found this:

      If you know how to access phpMyAdmin on your host, then you can edit these values directly.

      1 .Backup your database and save the copy off-site.
      2. Login to phpMyAdmin.
      3. Click the link to your Databases.
      4. A list of your databases will appear. Choose the one that is your WordPress database.
      5. All the tables in your database will appear on the screen.
      6. From the list, look for wp_options. Note: The table prefix of wp_ may be different if you changed it when installing.
      7. Click on the small icon indicated as Browse.
      8. A screen will open with a list of the fields within the wp_options table.
      9. Under the field option_name, scroll down and look for siteurl.
      10. Click the Edit Field icon which usually is found at the far left at the beginning of the row.
      11. The Edit Field window will appear.
      12. In the input box for option_value, carefully change the URL information to the new address.
      13. Verify this is correct and click Go to save the information.
      14. You should be returned to your wp_options table.
      15. Look for the home field in the table and click Edit Field. Note There are several pages of tables inside wp_options. Look for the > symbol to page through them.
      16. In the input box for option_value, carefully change the URL information to the new address.
      17. Verify this is correct and click Go to save the information.


      I backed up my databases locally and gave it a shot, changing both siteurl and home options from http to https.

      It worked! Woohoo! Sharing here for the reference of others who use MultiSite WordPress and have moved from http to https. Finally sorted! Thanks again for your part in my journey 🙂

      • ThemeSkills May 4, 2017 at 3:19 PM - Reply

        Hello! I’m happy that you worked it out and thanks for the info! I’ll also write a post how to properly move from HTTP to HTTPS.

  5. Enzo May 4, 2017 at 1:37 PM - Reply

    Thank you so much! 😉

  6. Nicola Boschetti March 29, 2018 at 12:59 PM - Reply

    Simply wonderful, you saved my life…!

  7. Daliso Ngoma April 18, 2018 at 6:31 PM - Reply

    Thank you for the article, was a life saver for me.

  8. Mary S. April 26, 2018 at 6:39 PM - Reply

    Thank you! A straightforward explanation. It worked perfectly.

  9. Sang Hyun Han May 25, 2018 at 9:10 PM - Reply

    I found “define(‘WP_HOME’,’http://example.com’); define(‘WP_SITEURL’,’http://example.com’);” lines on wp-config.php file, so I deleted, but I can’t still change the wordpress address. I checked functions.php file, but I coudn’t find those line.

    • Chris May 29, 2018 at 7:52 PM - Reply

      I’m having the same problem. The update_options lines are nowhere to be found in the functions.php file. I’m using Ocean WP theme.

  10. Nick June 14, 2018 at 7:25 AM - Reply

    I have looked tirelessly for a solution to this problem, and finally I stumbled across your site! Thank you so much!

  11. Nicholas June 21, 2018 at 12:10 AM - Reply

    Thanks for this post! Saved me some heartache. Worked like a charm.

Leave A Comment

Subscribe
SIGN ME UP

All Aboard!

Get WordPress guides and tutorials right in your inbox once per week, plus some cool   offers from time to time!
close-link