简体   繁体   中英

Dynamically setting permalink structure in Wordpress database creates 404

It seems like others have experienced similar issues as me in the past on this subject, but nobody has provided a complete answer.

I'm attempting to run a PHP script to update the permalink structure in the wp_options table for a slew of Wordpress blogs. I want to connect to each database and update the permalinks without having to log in to each blog and update the setting through the UI.

I'm successful at connecting to the DB and updating the permalink_structure field with the proper codes, but it causes a 404 when attempting to view any posts.

Is Wordpress updating other tables/fields to fully enable the permalink?? I'm having a hard time finding the complete answer to this.

BTW: If there are edits being made to the .htaccess when this is done through the Wordpress UI, I'm not seeing it. The htaccess looks unchanged when I do this through the UI.

Thanks!

Wordpress permalink rewrite_rules are kinda troublesome. They are great if you wanna do basic stuff, but it's damn hard to do some complex rules with it.

What exact structure you wanna use?

Remember that htaccess created by Wordpress just redirects everything to index.php, which loads Wordpress system (wp_load()), and one of its components parses REQUEST_URI.

First it tries to to bind REQUEST_URI into one of its regexes, which makes it understand what kind of resource is being requested (category, tag, page, post, etc), then it tries to find which resource it is (if it's a post, find which post by it's slug).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM