• Resolved rudym

    (@rudym)


    Hi,

    So I finally get a live site set up locally for development and it’s mostly ok. What I just noticed is that the links do not seem to work. So I go to the permalink settings through the dashboard, just to view, and suddenly Voila! All links work now upon clicking to view permalink settings. What gives?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Joms

    (@jomsky)

    WP caches rewrite rules. So when a plugin or a theme modifies a rule the cache should be regenerated to reflect the changes. This can’t be done on every page load since this will considerably slow the website down. So WordPress flushes the rewrite rules on the Permalink settings page.

    Thread Starter rudym

    (@rudym)

    Ok, I’m looking to mimic a similar thing using WP-CLI and figured something like:

    wp rewrite flush --hard --path=c:\xampp\htdocs\mywordpress

    But this doesn’t do it. In the permalinks page, it executes flush_rewrite_rules(). How can I execute this WP function?

    Joms

    (@jomsky)

    Just for context why/where do you want to flush the rewrite rules? If it’s for a plugin I suggest calling flush_rewrite_rules() on plugin activation/deactivation. You can find some code snippets here: https://codex.www.ads-software.com/Function_Reference/flush_rewrite_rules

    Thread Starter rudym

    (@rudym)

    My issue seems to be that once I download and deploy WordPress from backup in my localhost machine, the links don’t work right away. So, I log in and just VIEW the permalink settings, without saving, and the links work thereafter.

    I’m not sure why this is the case, but so far I haven’t found a way to mimic this without having to manually logging in to view the permalink settings. And, upon review of the options-permalink.php page, I just stumbled across the call to flush_rewrite_rules(), and thought this was the trick. But, as I alluded to, the wp-cli command doesn’t seem to do the trick. I even tried to alter this directly in MySQL, but still no dice.

    Thread Starter rudym

    (@rudym)

    This problem seems to occur whenever I deploy a backup of my wordpress, both DB and WordPress files.

    Thread Starter rudym

    (@rudym)

    Ok, one last thing that resolved this for me. Review the .htacess file (located in the root of your WordPress folder). It should be something like:

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Funky permalinks settings’ is closed to new replies.