WordPress: Changing The Site URL Manually

WordPress: Changing The Site URL Manually

This is not necessarily the best fix, it’s just hardcoding the values into the site itself. You won’t be able to edit them on the General settings page anymore when using this method.

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.

1. 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.

2. 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' );

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.

4. Load the login or admin page a couple of times. The site should come back up.

Important! Do not leave those lines in the functions.php file. Remove them after the site is up and running again.

Note: If your theme doesn’t have a functions.php file create a new one with a text editor. Add the php tags and the two lines using your own URL instead of example.com:.

<?php
update_option('siteurl','http://example.com');
update_option('home','http://example.com');
?>

Upload that to your theme directory. Remove the lines or the remove the file after the site is up and running again.

>>>

Here are some additional details that step you through transfering a LAN-based wordpress site into an externally accessible site as well enabling editing the wordpress site from inside the LAN.

Two important keys are router/firewall modifications and the “wait 10+ minutes” after making the changes at the end.

-using ssh to log into your server (nano is a server preinstalled text editor)
-$ nano /var/www/books/wp-content/themes/twentyeleven/functions.php
-add lines just after <?php

    update_option('siteurl','http://your.site.url:port/yourblog');
    update_option('home','http://your.site.url:port/yourblog');

-refresh your web browser using your external site url

   http://your.site.url:port/yourblog

-$ nano /var/www/books/wp-content/themes/twentyeleven/functions.php
-remove those lines you just added (or comment them out)
-access your router (these steps are for pfSense, other routers should have similar settings to look for/watch out for)
-add to firewall/nat table a line like this

        wan/tcp/port/LAN.server.IP/80

-add to firewall/rules table a line like this

        tcp/*/port/LAN.server.IP/port/*

-uncheck the box at System/advanced/network address translation/Disable NAT Reflection

       "Disables the automatic creation of NAT redirect rules for access to your public IP addresses from within your internal networks. Note: Reflection only works on port forward type items and does not work for large ranges > 500 ports."

Then go do something for ten minutes and when you get back see if the external url http://your.site.url:port/yourblog from a LAN browser brings the page up correctly.

Leave a Replay

Expanding Your Business Reach By Connecting You With The Right People

If you have made it this far then we know you want to succeed in your business. Need a new website? Need finding more customers? Need help in your Social Media presence? 

 

We are on a mission to tell as many success stories as we can

 

We tell the stories of forward-thinking organisations and create platforms that strategically reach their target audience.

 

If you’re ready to share your business story then your story then Contact Us Today.

Recent Posts

Follow Us

WordPress: Changing The Site URL Manually

Time to read: 2 min