wordpress - WordPress add_rewrite_rule() 显示 404 not found
问题描述
在 wordPress 中,我创建了一个名为 compare 的页面。因此,当我从浏览器 url 访问该页面时,我正在获取内容。(http://localhost/task/compare/)
add_action( 'init', 'custom_rewrite_rules');
function custom_rewrite_rules() {
add_rewrite_rule('^compare/([0-9]+)/?', 'index.php?page_id=250', 'top'); // Here 250 is the page id for compare
flush_rewrite_rules();
}
因此,当我尝试访问 url 中的页面时
http://localhost/task/compare/aa-bb-cc-dd
Its showing 404 not found error.
那么有人可以告诉我我在这里做错了什么吗?欢迎任何帮助和建议。
解决方案
在我看来,您应该尝试刷新永久链接。请参阅下面的链接。
推荐阅读
- sql-server - CICD 因“拒绝公共访问”而无法发布数据库
- python - 在没有静态文件的heroku中部署python API
- angular - 如何在 Jest Angular 中为 GroupBy 函数编写测试用例
- android - 我可以将 ML Kit 的人脸检测用于没有自动对焦的设备吗?
- android - 如何在 Fragment 中使用 TestActivity 继承的 Activity?
- reactjs - 页面刷新后我必须再次登录。React-router-dom 身份验证问题
- cuda - PTX 中的变量“已降级”是什么意思?
- python - 使 Absolute XPath 对测试更加健壮
- azure - Azure IoT Central 中 IoT Edge 模块的可写属性
- python - 如何用其他值 django 模型覆盖默认值