donglanfu5831 2018-09-17 18:34
浏览 59

WordPress查询字符串来改变SEO友好的URL

I want to create SCO friendly URL in the WordPress. Also, I have added a hook in my functions.php file as below code but not working.

My URL:http://bddlabs.com/webinar01/?id=pzlyglhbepotwpvbigdatadim_data&storyid=Story_997e9391-71d7-4fac-804b-de891c7aa595

I want http://bddlabs.com/webinar01/pzlyglhbepotwpvbigdatadim_data/Story_997e9391-71d7-4fac-804b-de891c7aa595

Is it possible? I am not sure about it. URL query string is coming from the third party, URL query string is coming from the third party, page content render based on query string.

Below code added landing-page-15.php it WordPress theme base page template

function fb_change_search_url_rewrite() {
    if ( ! empty( $_GET['storyid'] ) ) {
        wp_redirect( home_url( "/webinar01/" ) . urlencode( get_query_var( 'storyid' ) ) );
        load_template( realpath(__DIR__ . '/..') . '/landing-page-15.php' );        
        exit();
    }   
}
add_action( 'template_redirect', 'fb_change_search_url_rewrite' );
//additional rewrite rule + pagination tested
function rewrite_search_slug() {
    set_query_var('storyid', $_GET['storyid']);
    add_rewrite_rule(
        'find(/([^/]+))?(/([^/]+))?(/([^/]+))?/?',
        'index.php?id=$matches[2]&storyid=$matches[6]',
         'top'      
    );
}
add_action( 'init', 'rewrite_search_slug' );
  • 写回答

2条回答 默认 最新

  • dqqxkq4047 2018-09-17 18:54
    关注

    Wordpress can do this by default. https://codex.wordpress.org/Using_Permalinks

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题