2

I have my wordpress server set up using php, mysql, and apache on my raspberry pi. I also have a dynamic dns hostname and configured my router's port forwardiing settings.

When trying to access my server from outside of my local LAN, when I type in my dynamic dns host, (for example, my phone on 4G mobile network or at school), the site incorrectly redirects to the server's local IP address: 192.168.0.18 so the page fails to load up.

This is very weird because I also have owncloud set up on my pi and in the same condition I try to access mydynamicdnshost/owncloud, it doesn't redirect me to local IP and the page loads up successfully.

I know this is a really basic problem with wordpress configuration but I simply cannot fix it. So does anyone know that please answer my question. Many thanks!

3 Answers 3

1

Change the Site URL in Options Table.

UPDATE  `wp_options` SET  `option_value` =  'YOUR_SITE_URL' WHERE  `option_name` = 'siteurl' OR  `option_name` = 'home';

Also change the static URLs in your post content.

UPDATE `wp_posts` SET `post_content` = REPLACE(post_content, '192.168.0.18/YOUR_LOCAL_SITE_URL/', 'YOUR_SITE_URL/');

Don't forget to change the table prefix if its not 'wp_'.


Edit : Access PHPMyAdmin of your server. Contact your Hosting Provider if you are not aware of this.

Select your WordPress Database & Access wp_options table. And change 'siteurl' && 'home' attribute values to your Live Website URL.

Hire a developer if you are not sure what you are doing !

enter image description here

4
  • I am sorry, could you please tell me which file contains those configurations? I'm a completely newbie to this field. I tried to find them in wp-config.php, etc but none of them were found.
    – Tupopo
    Commented Apr 11, 2017 at 7:59
  • These settings are exposed on the Settings / General page too, as WordPress Address (URL) and Site Address (URL). This Codex page provides more information. But I'm not sure that the answer will work; I'd think that you need to update these settings to the dynamic hostname you're using, not to the local address. Commented Apr 11, 2017 at 9:53
  • Updated the answer. Commented Apr 11, 2017 at 10:45
  • @GaborBarat Agree, That the approach given i this codex page is better than my solution. But if its not done properly it will change the site and home url in options table on each and every request. Commented Apr 12, 2017 at 11:35
0

Inspired @jitendra-rana answer, the direction was correct, but not full.

  1. Do dump of your database to the file.
  2. Open dump file and replace all http://192.168.0.18 to http://your_site
  3. Execute dump file to replace all data in database.
  4. Clear cache (hard reload) of your site.

Profit.

0

In general, changing the WP_SITEURL and WP_HOME records in the wp_option table is not enough to make the entire website available. You need to change all the links, including image links, JS and CSS link, A tags, and in general, any link that goes out in html.

I have created a plugin and placed it in the WordPress repository, which publishes a website created on a local web server like Xampp/Wampp to the network. By setting your own Local IP in the plugin settings, your WordPress will be published in general on the network.

https://wordpress.org/plugins/local-to-ip/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.