admin管理员组文章数量:1426839
I've been trying to set up different rewrite rules on my multisite installation, but as of now, nothing is working. Even the simple
add_rewrite_rule('^welcome$', 'index.php?p=1', 'top');
isn't working.
Is there anything to do when setting up rewrite rules using the Rewrite API that needs to be done that isn't explicitity defined in the codex?
This problem led me to wonder: are rewrite rules written using the API supposed to be written in .htaccess or not?
Thank you in advance.
PS. If I'm duplicating, I am sorry, but I haven't been able to find a well written answer yet.
I've been trying to set up different rewrite rules on my multisite installation, but as of now, nothing is working. Even the simple
add_rewrite_rule('^welcome$', 'index.php?p=1', 'top');
isn't working.
Is there anything to do when setting up rewrite rules using the Rewrite API that needs to be done that isn't explicitity defined in the codex?
This problem led me to wonder: are rewrite rules written using the API supposed to be written in .htaccess or not?
Thank you in advance.
PS. If I'm duplicating, I am sorry, but I haven't been able to find a well written answer yet.
Share Improve this question asked May 15, 2019 at 7:34 user167290user167290 2 |1 Answer
Reset to default 0Found the answers:
- There is nothing to do when using the Rewrite API that isn't written in the Codex.
- Rules written using
add_rewrite_rule
are not added to.htaccess
. WP adds them to its database underrewrite_rules
in the_options
table.
It's important not to forget to:
- Filter the rewritten permalinks; call the functions on the
post_type_link
hook and/or theterm_link
hook depending on the situation. - Remove default rules to avoid conflict and call the function/s on the
rewrite_rules_array
hook. - Flush and rewrite the rules using
flush_rewrite_rules();
on plugin activation and/or deactivation.
本文标签: url rewritingRewrite rules in multisite
版权声明:本文标题:url rewriting - Rewrite rules in multisite 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745484226a2660309.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
global $wp_rewrite; $wp_rewrite->init(); $wp_rewrite->flush_rules();
andflush_rewrite_rules();
. – user167290 Commented May 15, 2019 at 8:28