最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

url rewriting - add_rewrite_rule refuses to function

programmeradmin2浏览0评论

I am trying to create a custom redirect on my local machine using MAMP. From the Wordpress codex I have the following code as a simple starting point. No matter what I try I cannot get this simple solution to function as expected. I am running the latest version of Wordpress, I have saved the permalinks to flush the redirects and changed the theme to eleminate this as variable. My xampp has mod_rewrite enabled.

I simply want to redirect: /?p=95 to

The code is as follows:

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

My htaccess is the basic wordpress version and I am not using any plugins in my build.

Any help will be greatly appreciated.

发布评论

评论列表(0)

  1. 暂无评论