Support » Localhost Installs » Running Locally With Different Addressing Modes

  • I’ve set up two WordPress websites that work fine online. I like to do development for both of them on a local computer and then put my changes in online. The first one, which I set up in November 2015 and is currently running WordPress 4.6.1, works fine both online and locally. All I have to do to get it to run locally is to download the online database and run the following SQL query to change the addresses in the local database:

    UPDATE wp_options SET option_value = replace(option_value, ‘http://www.seniornetli.org’ , ‘http://192.168.1.221/SeniorNetLI/public_html/’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
    UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.seniornetli.org’ , ‘http://192.168.1.221/SeniorNetLI/public_html/’);
    UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.seniornetli.org’ , ‘http://192.168.1.221/SeniorNetLI/public_html/’);

    The second website, which I set up in September 2016, doesn’t work completely. I can view the home page, but can’t view any other page in the menu. When I try I can an error message like, “The requested URL /LISF/public_html/home/wp/thermal-duration/ was not found on this server.” By the way, to get the home page to work I ran the following SQL query to change the addresses in the local database:

    UPDATE wp_options SET option_value = replace(option_value, ‘http://www.lisf.org’ , ‘http://192.168.1.221/LISF/public_html’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
    UPDATE wp_posts SET post_content = replace(post_content, ‘http://www.lisf.org’ , ‘http://192.168.1.221/LISF/public_html’);
    UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘http://www.lisf.org’ , ‘http://192.168.1.221/LISF/public_html’);

    I also updated the local .htaccess file:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /LISF/public_html/home/wp/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /LISF/public_html/home/wp/index.php [L]
    </IfModule>

    # END WordPress

    So I can view the home page of the new website and do administration locally. I can even create a test webpage and see it in preview changes. However, if I publish that webpage and put it into the menu I can’t open it, getting the same type of error message as above.

    What I have noticed is that the addresses used for the two websites are different. The older one uses something like, “http://www.seniornetli.org/?page_id=82&#8221;. The newer website uses something like, “http://www.lisf.org/home/how_to_join/how_to_join_rwd.html&#8221;: without the page_id. (The newer version is much nicer.)

    What I need is to be able to use the new addressing mode, which I seem to be stuck with, locally or just a good description of what’s going on that will help me get this working.

    Development is being done locally on a LinuxMint 18.0 machine and I use ftp to upload the WordPress files to the web hosts.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    It’s possible you will break serialized data with your queries. Use the plugin “better search and replace” to search and replace, as it’s sensitive to serialized data.

    Steve, Thanks for you input. It turned out that using the Better Search and Replace plugin on a local copy of the problem website was a bit of a chicken and egg problem in itself. WordPress wouldn’t go into administration mode run unless I changed the links (addresses) in the local database as above. Once I got past that I was able to load and run Better Search and Replace, which was too little too late after I potentially created the same problem with serialized data all over again. At least it found one link that I missed.

    Anyway, I finally found the problem and the solution. Permalinks. Apparently the (old) website that I could run properly locally had its permalink common setting to “plain”. The (new) website that I couldn’t run properly locally had its permalink setting to “Day and name”. (Has WordPress changed its default setting for permalinks?) By switching my permalink setting from “Day and name” to “Plain” the local website started working normally: meaning that I could use the menu to switch between pages. And I could see in the web address that it had switched to using the page_id= addressing mode.

    So I get to have my cake and eat it, too. I get the friendly url for the website on the internet and still have it work locally with the not so friendly query string in the permalink.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Running Locally With Different Addressing Modes’ is closed to new replies.