Help! I Messed Up My WordPress URL Settings

If you’ve found this article, it is probably because you made a mistake when updating your WordPress url settings, and now need a solution for reversing your changes. And the problem that you have likely encountered is that the WordPress admin area is inaccessible. So you can no longer make changes via the WordPress interface.

Fortunately, if you can edit and upload files, or have direct database access, you can easily reverse the changes.

Edit and Upload functions.php

The simplest way to reverse the changes it to edit your theme’s functions.php file.

Each theme generally has a functions.php file. It will be located in your active theme’s directory at:
root -> wp-content -> themes -> [theme name] -> functions.php

Once you’ve found this file, you will need to edit it by adding the following code at the very top of the file, but within the opening <?php tag.


If your theme does not have a functions.php file, you will need to create one. Inside of it place the following code:


Be sure to edit the code to reflect the url settings for your blog, and then upload this file to your theme’s directory. Now attempt to access your admin area. Note: You might need to reload or refresh the page a few times. When you have successfully loaded the website, edit the functions file again to REMOVE those lines that you added. Now your settings should be fixed.

Database Fix: SQL Query

If, for some reason, the above method does not work, you can accomplish the same fix by directly editing the database.

Once you have access to the database, either via phpMyAdmin or through some other database utility tool, you will need to run the following query.

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

Note: You will need to update this code to reflect the url for your website. Additionally, if your website uses something other than the default database table prefix, you will need to update the wp_ prefix in wp_options to reflect the name of your options table.

And that’s all. Your settings should now be fixed.

‘WordPress Address’ vs ‘Blog Address’

The reason why it is so easy to mess up your settings is because the difference between WordPress Address and Blog Address is not well explained. The WordPress Address is the location where WordPress is installed. Or in other words, it is the directory where you will find the WordPress files. On the other hand, the Blog Address is the location where the home page of the blog will be.

In most cases, the WordPress Address is the same as the Blog Address. However sometimes, such as if you want to keep WordPress files separate from other files, you might place WordPress files in their own directory. For additional information on this topic, visit the WordPress documentation on Giving WordPress Its Own Directory.

Tags: ,

63 Responses to “Help! I Messed Up My WordPress URL Settings”

  • Kim Woodbridge December 22, 2008 at 9:19 am

    Hi – Do you think that most people who make this mistake will be able to follow those instructions? ;-) My guess is no – I know that we could (I’ve actually done it and fixed it through the database) but so many users that I encounter don’t know how to FTP much less edit the database.

  • waseem December 28, 2008 at 4:46 pm

    thank you so much, i nearly freaked out!

  • Rubal January 22, 2009 at 4:39 am

    Thank you!!
    This is life saver.

  • Eric P March 9, 2009 at 12:12 am

    Thanks for the tip! Very nice.

    Based on it, I created the following function (permanently add to functions.php) to enable dynamic assignments of the siteurl and home option values. This is useful to our shop as we copy the same theme to many different URLs.

    update_siteurl(); // call the function at the top of functions.php

    function update_siteurl() {
    $option_siteurl = get_option('siteurl');
    $option_home = get_option('home');
    if ( !strstr($_SERVER['HTTP_HOST'],$option_siteurl) ) {
    update_option('siteurl', 'http://'.$_SERVER['HTTP_HOST']) ;
    update_option('home', 'http://'.$_SERVER['HTTP_HOST']) ;

    You could also make this function a call from the set up menu somewhere (or based on a unique REQUEST_URI string request) to lessen the overhead of grabbing the variables on each request.

  • Hyrum March 28, 2009 at 8:44 pm

    You are awesome! Thanks for the help. I was able to put everything back in order.


  • Alex May 1, 2009 at 12:38 am

    Thank you so much! I am so happy I found your site.

  • Joel May 20, 2009 at 4:36 pm

    My blog is installed in a secondary domain on my webhost account. That is, there is primary account, but I can host other domains. It is in a folder of the primary account: (where ‘second’ is the folder where the site is installed and hosted.

    If I browse to the second domain using, the address looks fine when I first hit the site. But when I browse to another page, I get and so on.

    In the WP settings, the URLS are both

    Should I change the BLOG address to

  • Heather June 26, 2009 at 6:15 pm

    Thank you thank you thank you! This helped me so much! And Kim– don’t always discount people who don’t know what they’re doing. I have honestly never really messed with my database at all because I’m always too scared I’ll screw something up (I tend to do that, hence, I’m reading this post), so I didn’t even know how to get my SQL database… but I figured it out and had everything fixed in about five minutes! Yay! Thank you!

  • Cyndi G August 27, 2009 at 12:57 pm


  • nick rafique September 29, 2009 at 7:21 pm

    thanks very much for providing this handy tip for siteurl vairable overwrite . I have blog on my website . But my website on godady shared hosting and I need to run sitemap script . so I run sitemap script locally . this variable overwrite tip is very handy and I dont need to update my database from local to remote server . just use if condition


  • Anthony Mendez January 5, 2010 at 7:13 pm

    Brilliant! The function.php method worked for me. Thanks.

  • TDB January 18, 2010 at 1:19 am

    Thanks for your useful post. Finally I recovered up the blog..

  • Cory Mink (Yawning Yeti) January 22, 2010 at 12:15 am

    You have no idea how much help this post was. One of the editors on my site was changing around the front page and some how ended up changing the wordpress url. After almost having a nervous breakdown I stumbled across your site, and you saved me from throwing my monitor out the window :) Thank you so much!

  • Lilx February 1, 2010 at 8:52 am

    Thank you very much. Saved my life.

  • Chris Scott February 12, 2010 at 12:11 pm

    It only worked for me when I inserted:

    and not:


    I got a parse error when I tried to insert the second line.

  • Robert March 14, 2010 at 12:41 pm

    Thank you sooooooo much. You’re a life saver!

  • Mocomedia April 23, 2010 at 11:32 pm

    THANK YOU!!! ;)

  • Jared Tseng May 27, 2010 at 5:04 am

    Thank you. I almost had a panic attack.

  • John Media @ host server June 9, 2010 at 10:12 am

    I would appreciate it more if you’d include some screen shots and stating it much more clearly the topics and what really is the problem but either way its a great post I must say thanks ^^,

  • Lucy@Devil’s Grippe June 22, 2010 at 6:58 pm

    Thank you so much!! That really really helped me. I thought I was going to have to start all over.

  • dani July 6, 2010 at 4:01 am

    I am getting the following error. What does this mean?

    Fatal error: Cannot redeclare get_alloptions() (previously declared in /home/content/d/s/t/dstolfi808/html/savetheseaturtles/wp-includes/functions.php:419) in /home/content/d/s/t/dstolfi808/html/savetheseaturtles/wp-includes/deprecated.php on line 1876

  • Kazimir July 20, 2010 at 9:02 am

    Thank you very much, i restored my blog ( thanks to god and you !! ) by editing the database

  • Mattz July 23, 2010 at 3:12 pm

    this is soooo hard to follow. isn’t there an easier way?

  • Jeff August 9, 2010 at 1:52 pm

    I thought these instruction were sweet. Lifesaver. Thank you. You got to love the people with negative comments who think you owe them something. Haaa…

  • Chris Gray August 29, 2010 at 5:03 pm

    This was so helpful! I spent hours last night trying to figure this out. Codex was completely useless! You’re not a life saver, but a 16-20 hour saver of me rewriting pages of content. Thanks so much!

  • plin September 29, 2010 at 10:26 pm

    That worked for me for the site in general but it didn’t work for the images within the post. Any quick fix for this?

  • Mark November 3, 2010 at 1:01 pm

    Holy crap… you saved my ass, sir! Thank you!

  • Tom December 19, 2010 at 1:50 pm

    Just want to give a big thanks for this fix! I don’t know much about this type of coding, but was able to figure it out quickly and get everything fixed. Thanks again!

  • Anas Munir December 25, 2010 at 7:41 pm

    I cant believe it..
    I thought I lost everything…
    You are a life saver man…
    Thanks alot…

  • Josh Groce January 28, 2011 at 4:45 pm

    Saved my life!

  • Matt February 7, 2011 at 9:17 pm

    Seriously just saved my ass a lot of time and trouble.

    Thank you very much.

  • Roger March 18, 2011 at 8:09 am

    Thanks for the work-around for the changed WP URL in settings!

  • EJ DeCoske March 30, 2011 at 1:18 pm

    After replacing my current site (client’s site) with a backup from an old location my site went pear shaped and gave me a momentary anxiety attack. I used your solution coupled with your Velvet Blues Update URLs and it saved me hours of time and heart ache. Thanks for the great resource and the clear explanations!

  • Hari March 31, 2011 at 9:18 am

    Thanks a ton!

  • Nelson May 25, 2011 at 11:12 pm

    Dude, you saved my life. Awesome tip!

  • Debs June 18, 2011 at 12:38 pm

    I love you.

  • Veridique Online Transcription July 30, 2011 at 10:32 pm

    Good Lord, THANK YOU! I completely’d screwed meself.

  • michelle August 3, 2011 at 12:29 am

    you saved my bacon, thanks for posting this :-)

  • Beth September 10, 2011 at 8:39 am

    Hi, Thanks so much for this help! I did this and it fixed my homepage, but my other pages are still not being found…is there something else i need to do? If possible could you help me out. I would greatly appreciate it :)

  • Kel October 31, 2011 at 4:59 pm

    Thank you Thank you Thank you Thank you Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    I just transferred a domain to my blog, and without realizing that the change hadn’t gone through yet, I changed the wordpress url.

  • Sam October 31, 2011 at 11:34 pm

    Saved my life. Thanks.

  • Amy November 11, 2011 at 7:47 am

    Thanks. Brilliant help and in response to ” Do you think that most people who make this mistake will be able to follow those instructions?” – YES! I am quite able to make a stupid mistake like that and still smart enough to follow the instructions ;-)

  • Daniel Hollands November 16, 2011 at 11:31 am

    Since WordPress 2.2, you’re able to define the siteurl and home settings in your wp-config.pfp file.

    Provided you’re running WordPress from the root of the domain, simply put the following code anywhere in your wp-config.php file, and it will automatically set the correct domain for you:

    define(‘WP_SITEURL’, ‘http://’ . $_SERVER['HTTP_HOST']);
    define(‘WP_HOME’, ‘http://’ . $_SERVER['HTTP_HOST']);


  • Vincent December 29, 2011 at 12:15 pm

    Thank you so much!!! You saved hours work for me.

    I used option 2

    Remember: if you have changed the wp_ prefix! (I did)

    Thanks again

  • Aris Albaitis February 7, 2012 at 3:49 pm

    Saved my ass! Thank you!

  • Tove February 24, 2012 at 4:21 am

    Shit, really helpfull page. I freaked out for a moment there. But you saved my butt. Thanks!

  • Martyn Milne March 6, 2012 at 12:49 pm

    Thank you – genius!

  • erwin tan March 14, 2012 at 3:20 pm

    now that ive fixed that problem and thank you BTW. now my blog is saying a http 404 error.

  • Paul R. De Buck June 13, 2012 at 4:33 pm

    It’s the second time you save my whole website ! I’m so dumb making twice the same mistake –”.. Thanks !

  • Joanne July 17, 2012 at 3:48 am

    You are an angel!!!!!!!!

  • Unimportant July 25, 2012 at 12:30 pm

    Thank you so much!

  • chantel August 13, 2012 at 2:27 pm

    I added the code, but it still won’t allow me to view the wordpress site. Is there something special you have to do if you have Godaddy?

  • Jack Donga September 14, 2012 at 9:26 pm

    Thank you so much you saved me!

  • vandana October 31, 2012 at 1:34 pm

    thnx ….

  • Dima November 5, 2012 at 3:11 pm

    You can create WordPress URL Settings so

    2…Databases…/blog WordPress
    3…localhost »blog »wp_options
    4…option_id 1 ..
    5…team edit
    6…write a new URL

  • Ricky November 13, 2012 at 9:31 pm

    You are a lifesaver!!!!

  • Jameel Alayyan February 18, 2013 at 3:50 pm


  • Angie M. Photography February 25, 2013 at 4:44 pm

    Thank you so much for this. I nearly had a heart attack when I accidentally changed one of the URL’s. My issue is getting Flickr to connect to a self hosted wordpress blog. Still trying to figure that one out, but I sure won’t make the same mistake again! Thanks a million.


How to Change WordPress Directory Name or Location | Jeff King Consulting

Trackback URL:

Leave a Reply

Want us to work on your project?

Contact us today for a quote. Click here to submit details regarding your project.

If you are making a general inquiry, send an email to

Go Daddy Deal of the Week: Cheap .COM Domains! Offer expires soon!