2016-09-20 140 views
-1

https://codex.wordpress.org/Rewrite_API/add_rewrite_ruleWordPress的重写规则不起作用

我想改变我的网址对用户友好的永久链接。 所以我用我的functions.php中的wordpress提示,但没有发生任何事情! 我不知道它是因为我的链接。

这里是我的示例页面谁应该更改网址: [我的样品页] [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'); 

其实我想更改此网址:页/ CMD =艺术家

到:/艺术家

这个网址:页/ CMD = artist_detaile & ID = 31

到:/ DJ-塔巴

所以什么是我错了吗? 请帮忙。

通过自己**解决问候


问题

回答

0

具有u启用在WP设置use permalinks选项?如果不这样做。

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

我希望它会有所帮助。

+0

是的,我做到了。我的.htaccess文件也使用WordPress的默认规则(设置>永久链接)。 – pdesigner