【问题标题】:WordPress rewrite rules not workingWordPress重写规则不起作用
【发布时间】:2018-08-17 01:10:33
【问题描述】:

基于WordPress rewrite rules,我想将我的网址更改为用户友好的永久链接。 所以我在我的functions.php中使用了WordPress提示,但什么也没发生!

我不知道这似乎是因为我的链接。

这是我应该更改 url 的示例页面: [我的示例页面][2]

这是我在functions.php中的代码:

function custom_rewrite_basic() {
  add_rewrite_rule('^music/([0-9]+)/?', 'index.php?page_id=$matches[1]&cmd=artist', 'top');
}
add_action('init', 'custom_rewrite_basic');

其实我想改这个网址:

page/?cmd=artist

/artists

或者这个网址:

 page/?cmd=artist_detaile&id=31

 /dj-taba

那么我的错误是什么?


自己解决的问题**

【问题讨论】:

    标签: wordpress url-rewriting permalinks


    【解决方案1】:

    您是否在 WP 设置中启用了use permalinks 选项?如果不这样做。

    您还需要在 .htaccess 文件或直接在服务器 conf 文件中打开重写模式。

    我希望它会有所帮助。

    【讨论】:

    • 是的,我以前做过。我的 .htaccess 文件也使用 wordpress 默认规则(设置 > 永久链接)。
    猜你喜欢
    • 2013-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-13
    • 2015-01-31
    • 2015-09-01
    • 2019-12-13
    • 2017-05-30
    相关资源
    最近更新 更多