admin管理员组文章数量:1287934
I want to redirect mywebsite/anyname.html to mywebsite/product/anyname For that I write the following query in functions.php . But it is not working . Please see my code below
function custom_rewrite_basic() {
add_rewrite_rule('^(.*)\.html$', '/product/$1');
}
add_action('init', 'custom_rewrite_basic');
Please help to solve the issue.
I want to redirect mywebsite/anyname.html to mywebsite/product/anyname For that I write the following query in functions.php . But it is not working . Please see my code below
function custom_rewrite_basic() {
add_rewrite_rule('^(.*)\.html$', '/product/$1');
}
add_action('init', 'custom_rewrite_basic');
Please help to solve the issue.
Share Improve this question edited Sep 14, 2021 at 6:54 Abilash Erikson asked Sep 14, 2021 at 6:51 Abilash EriksonAbilash Erikson 1251 silver badge10 bronze badges 01 Answer
Reset to default 1Or you could just add the relevant directive to the top of the .htaccess
file directly. For example:
RewriteRule ^([^/]+)\.html$ /product/$1 [R=302,L]
This matches /anyname.html
(as in your example), but not /foo/bar/anyname.html
.
本文标签: url rewritingaddrewriterule fro html to another url not working
版权声明:本文标题:url rewriting - add_rewrite_rule fro html to another url not working 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741321387a2372223.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论